Home  >  Article  >  Database  >  What is a temporary table in mysql

What is a temporary table in mysql

青灯夜游
青灯夜游Original
2019-05-07 17:55:032540browse

MySQL temporary tables are very useful when we need to save some temporary data. So what are temporary tables? The following article will introduce it to you, I hope it will be helpful to you.

What is a temporary table in mysql

The temporary table is a table used by MySQL to store some intermediate result sets. The temporary table is only visible in the current connection. When the connection is closed, Mysql will automatically delete the table and release all space. Why is a temporary table generated? Generally, it is due to complex SQL that a large number of temporary tables are created.

Temporary tables were added in MySQL version 3.23. If your MySQL version is lower than version 3.23, you cannot use MySQL's temporary tables. However, nowadays it is generally rare to use such a low version of the MySQL database service.

Temporary tables are divided into two types, one is a memory temporary table and the other is a disk temporary table. The memory temporary table uses the memory storage engine, and the disk temporary table uses the myisam storage engine (disk temporary tables can also use the innodb storage engine. Use the internal_tmp_disk_storage_engine parameter to control which storage engine is used. From mysql5.7.6 onwards, the default is innodb storage. Engine, previous versions defaulted to myisam storage engine). Use the Created_tmp_disk_tables and Created_tmp_tables parameters to view how many disk temporary tables are generated and all generated temporary tables (memory and disk).

The above is the detailed content of What is a temporary table in mysql. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn