最新文章专题视频专题问答1问答10问答100问答1000问答2000关键字专题1关键字专题50关键字专题500关键字专题1500TAG最新视频文章推荐1 推荐3 推荐5 推荐7 推荐9 推荐11 推荐13 推荐15 推荐17 推荐19 推荐21 推荐23 推荐25 推荐27 推荐29 推荐31 推荐33 推荐35 推荐37视频文章20视频文章30视频文章40视频文章50视频文章60 视频文章70视频文章80视频文章90视频文章100视频文章120视频文章140 视频2关键字专题关键字专题tag2tag3文章专题文章专题2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章专题3
当前位置: 首页 - 科技 - 知识百科 - 正文

MySQL–BeginningTemporaryTablesinMySQL_MySQL

来源:动视网 责编:小采 时间:2020-11-09 19:18:08
文档

MySQL–BeginningTemporaryTablesinMySQL_MySQL

MySQL–BeginningTemporaryTablesinMySQL_MySQL:MySQL supports Temporary tables to store theresultsetstemporarily for a given connection. Temporary tables are created with the keyword TEMPORARY along with the CREATE TABLE statement.Let us create the temporary table named TempCREATE TEMPO
推荐度:
导读MySQL–BeginningTemporaryTablesinMySQL_MySQL:MySQL supports Temporary tables to store theresultsetstemporarily for a given connection. Temporary tables are created with the keyword TEMPORARY along with the CREATE TABLE statement.Let us create the temporary table named TempCREATE TEMPO
 MySQL supports Temporary tables to store theresultsetstemporarily for a given connection. Temporary tables are created with the keyword TEMPORARY along with the CREATE TABLE statement.

Let us create the temporary table named Temp

CREATE TEMPORARY TABLE TEMP
(id INT);

Now you can find out the column names using DESC command

DESC TEMP;

The above returns the following result

This table can be accessed only for the current connection and it can be used like a permanent table and automatically dropped when the connection is closed. However, you can not find temporary tables using INFORMATION_SCHEMA. TABLES system view. It will only list out the permanent tables.

MySQL usually stores the data of temporary tables in memory and processed by Memory Storage engine. But if the data size is too large MySQL automatically converts this to the on – disk table and use MyISAM engine.

You can also create a permanent table with the same name of a temporary table in the same connection. However the structure of permanent table is visible only if the temporary table with the same name is dropped.

Let us create a permanent table with the same name Temp as below

CREATE TABLE TEMP
(id INT,
names VARCHAR(100));

Now running the following command stills gives you the structure of the temporary table temp created earlier.

DESC TEMP;

You can drop the temporary table using DROP TEMPORARY TABLE command;

DROP TEMPORARY TABLE TEMP;

After you executed the temporary table, run the following command

DESC TEMP;

Now you will see the structure of the permanent table named temp

In summary– If there is a Temporary Table in MySQL it gets first priority over the permanent table in the session.

Reference: Pinal Dave (http://blog.sqlauthority.com)

文档

MySQL–BeginningTemporaryTablesinMySQL_MySQL

MySQL–BeginningTemporaryTablesinMySQL_MySQL:MySQL supports Temporary tables to store theresultsetstemporarily for a given connection. Temporary tables are created with the keyword TEMPORARY along with the CREATE TABLE statement.Let us create the temporary table named TempCREATE TEMPO
推荐度:
标签: mysql table mys
  • 热门焦点

最新推荐

猜你喜欢

热门推荐

专题
Top