MySQL temp table

Source: Internet
Author: User

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

Related Article

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.