Analysis of the principle and creation method of Mysql temporary table

Analysis of the principle and creation method of Mysql temporary table

This article mainly introduces the principle and creation method of Mysql temporary table. The example code in this article is very detailed and has a certain reference value for everyone's study or work. Friends in need can refer to it.

mysql can create a temporary table using the temporary keyword. The created table will automatically disappear when the session with the server ends.

Syntax: create temporary table tbl_name...;

Rules: Each session can only see the temporary tables it created. Different sessions can create temporary tables with the same table name. The name of a temporary table can be the same as that of a permanent table.

Advantages: You can use temporary tables to save some temporary data, and automatically clear the data when the session is disconnected

harm:

1. If you accidentally disconnect from the server, the temporary table will be deleted.

2. Temporary tables are only visible to the session that created them, so they cannot be used simultaneously with thread pool connection technology.

3. It may conflict with the permanent table, resulting in incorrect operation of the permanent table data after reconnection. To avoid deleting permanent tables with the same structure, you can use drop temporary table_name when deleting the table structure;

Create a temporary table

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

ps: The temporary table is created, but cannot be seen using show tables

The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM.

You may also be interested in:
  • Basic learning tutorial of MySQL memory table
  • How to create a memory table in mysql
  • Using cursor loop to read temporary table in Mysql stored procedure
  • Examples of using temporary tables in MySQL
  • Detailed explanation of the difference between Mysql temporary table and partition table
  • Detailed explanation of the usage of MySQL memory tables and temporary tables

<<:  Mysql backup multiple database code examples

>>:  React Native startup process detailed analysis

Recommend

How to deploy HTTPS for free on Tencent Cloud

Recently, when I was writing a WeChat applet, the...

Web page html special symbols html special characters comparison table

Special symbols Named Entities Decimal encoding S...

Detailed explanation of creating stored procedures and functions in mysql

Table of contents 1. Stored Procedure 1.1. Basic ...

Five things a good user experience designer should do well (picture and text)

This article is translated from the blog Usability...

Abbreviation of HTML DOCTYPE

If your DOCTYPE is as follows: Copy code The code ...

element-ui Mark the coordinate points after uploading the picture

What is element-ui element-ui is a desktop compon...

Zen coding for editplus example code description

For example, he enters: XML/HTML Code div#page>...

A brief description of the relationship between k8s and Docker

Recently, the project uses kubernetes (hereinafte...

HTML Basics - Simple Example of Setting Hyperlink Style

*** Example of setting the style of a hyperlink a...

MySQL msi installation tutorial under windows10 with pictures and text

1. Download 1. Click the latest download from the...