Tuesday 20 April 2010

What is TEMP TABLES in mysql?

The temporary tables could be very useful in some cases to keep temporary data. The most important thing that should be knows for temporary tables is that they will be deleted when the current client session terminates.


As stated earlier temporary tables will only last as long as the session is alive. If you run the code in a PHP script, the temporary table will be destroyed automatically when the script finishes executing. If you are connected to the MySQl database server through the MySQL client program, then the temporary table will exist until you close the client or manually destroy the table.


for example:

mysql> CREATE TEMPORARY TABLE employee(
    -> emp_name VARCHAR(50) NOT NULL
    -> , emp_age INT(11) NOT NULL DEFAULT 
-> , emp_class int(11) NOT NULL DEFAULT
);
 
Query OK, 0 rows affected (0.00 sec)
Cheers!

No comments:

Post a Comment