Temporary table is used to store the temporary record which can be reused in a single session. Temporary tables are created from the existing tables and these tables are drops once the session ends or connection is terminated but you can also use DROP TABLE statement to drop a temporary table. Temporary tables can only be accessed by the client who has created the table. That is, different clients can create same name temporary table but in different sessions. Temporary table can have the same name as an existing table. That is, whenever you issue a request to a existing table it will refer to the temporary table. Once you drop the temporary table you can the access the existing table. Temporary Tables are created using CREATE TEMPORARY TABLE statement.
Creating Temporary Tables:
Syntax:
CREATE TEMPORARY TABLE temp_tblname
SELECT statements.
Example:
Create temporary table temp_emp
select name, dob from employees
Dropping Temporary Tables:
Syntax:
DROP TEMPORARY TABLE temp_tblname
Example:
DROP TEMPORARY TABLE temp_emp
0 Comment(s)