Mysql how to create a temporary table

mysql temporary use keywords to create a temporary table. This table is created automatically disappear when terminating the session with the server

语法:create temporary table tbl_name...;

Rules: Each session can only see their own to create a temporary table, different sessions can create a temporary table with the same table name. Table name and the name of the temporary table can be the same as a permanent table.

Benefits: You can use a temporary table to save some temporary data, clear data automatically disconnects the session
disadvantages: 1 server accidentally disconnected session, the temporary table will be deleted.
      2. The temporary table to create a session visible, so the thread pool and connection technology can not be shared at the same time
   3. may conflict with a permanent table, leading to misuse the data types of permanent table after the reconnection. To avoid permanently remove the same table shows that, when the delete table structure can use the drop temporary table_name;

 

Create a temporary table

create temporary table student_copy(
  id int primary key,
  name varchar(20) 
)Engine=InnoDB default charset utf8;

 

ps: a temporary table is created, unseen by show tables

Guess you like

Origin www.cnblogs.com/yachao1120/p/12059144.html