When you create a temporary table, you can use the TEMPORARY keyword. Such as:
Create temporary table tmp_table (name varchar (ten) not null,passwd char (6) NOT null) '
Or
CREATE Temporary TABLE IF not EXISTS sp_output_tmp ENGINE = MEMORY SELECT ... from ... where Id=curr ent_id;
The temporary table is only visible at the current connection and will be automatically drop when the connection is closed. This means that you can use the same temporary table names in two different connections, do not conflict with each other, or use tables that already exist, but not the table names of the temporary tables. (When this temporary table exists, the existing table is hidden, and if the temporary table is drop, the existing table is visible). Create temporary tables you have to have
Create temporary table permissions.
The following points are restrictions on temporary tables:
Temporary tables can only be used in Memory,myisam,merge, or InnoDB
Temp table does not support MySQL cluster (cluster)
In the same query statement, you can only find temporary tables once. For example: The following is not available
Mysql> SELECT * from Temp_table, temp_table as T2;
ERROR 1137:can ' t reopen table: ' Temp_table '
If you are using a different alias to find a temporary table multiple times in a stored function, or if you are using a different statement in this storage function, this error will occur.
The show tables statement does not enumerate temporary tables
You can't use rename to rename a temporary table. However, you can alter TABLE instead:
Mysql>alter TABLE orig_name RENAME new_name;
Remember to drop the temporary table when you're done with it:
DROP Temporary TABLE
IF EXISTSsp_output_tmp;
?
? http://www.cnblogs.com/end/archive/2011/03/31/2001094.html
MySQL temp table