Parsing Mysql temporary tables and features

Source: Internet
Author: User

A temporary table exists when the connection is not disconnected. Once it is disconnected, it does not exist. The data and structure of the temporary table are in the memory. You can perform a test to create a temporary table, but it is not found in the response data directory. frm File
Mysql> create temporary table tmp_table (
->
-> Name VARCHAR (10) not null,
-> Value INTEGER NOT NULL
->
-> );
Query OK, 0 rows affected (0.38 sec)

View table status
Mysql> show create table tmp_table \ G
* *************************** 1. row ***************************
Table: tmp_table
Create Table: create temporary table 'tmp _ table '(
'Name' varchar (10) not null,
'Value' int (11) NOT NULL
) ENGINE = InnoDB default charset = utf8
1 row in set (0.00 sec)

It is no different from a normal table, but the data is stored in the memory. You cannot find the data file in the response data directory.
Once the connection is disconnected, you can check the table again.

Similar to a temporary table, a memory table is also called a heap table.
Mysql> create table mem_table (
->
-> Name VARCHAR (10) not null,
-> Value INTEGER NOT NULL
->
->) TYPE = HEAP;
Query OK, 0 rows affected, 1 warning (0.01 sec)

View table status
Mysql> show create table mem_table \ G
* *************************** 1. row ***************************
Table: mem_table
Create Table: create temporary table 'mem _ table '(
'Name' varchar (10) not null,
'Value' int (11) NOT NULL
) ENGINE = memory default charset = utf8
1 row in set (0.00 sec)

You can find a mem_table.frm file in the data directory, so the data in the memory table is stored on the disk. However, after inserting the data, you can find that there are no data files on the disk, so the data is stored in the memory, because memory engine is used. Once the data is down, it does not exist. Because the data in the table is in the memory, the data will be fast. The disadvantage is security.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.