Temporary table in mysql

xiaoxiao2021-03-06  60

Temporary table in mysql ------------------------------------------- -------------------------------------------------- - Source: When you work in a very large table, you may take a lot of queries to get a large amount of data, not to run these queries throughout the table, but let MySQL find out each time. A small number of records that you need to select a record to a temporary table, and then multi-these tables run the query.

Creating a temporary table is easy, add Temporary keywords to normal CREATE TABLE statements:

Create Temporary Table TMP_TABLE (Name Varchar (10) Not Null, Value Integer NOT NULL

The temporary table will exist during your connection MySQL. When you disconnect, MySQL will automatically delete the table and release the space used. Of course, you can delete the table and release space when it is still connected.

DROP TABLE TMP_TABLE

If you have a TMP_TABLE table that is called TMP_TABLE Temporary table already exists in the database, the temporary table will be the necessary mask (hidden) non-temporary table TMP_TABLE.

If you declare that the temporary table is a Heap table, MySQL also allows you to specify in memory:

Create Temporary Table TMP_TABLE (Name Varchar (10) Not Null, Value Integer Not Null Type = HEAP

Because the Heap table is stored in memory, your query it runs is faster than the temporary table on the disk. However, the HEAP table is different from the general table and has its own limitations. See the mysql reference manual for details.

As mentioned earlier, you should test the temporary table to see if they are really more than a large number of databases. If the data is very good, the temporary table may be unhappy.

转载请注明原文地址:https://www.9cbs.com/read-112389.html

New Post(0)