mysql (create temporary table table_name )临时表创建

一般在数据量比较大的查询中,用in()等查询条件,会严重影响查询效率。

这时可以用  create temporary table table_name select id,name from table    创建临时表

使用临时表时注意事项:

1.自己所用的数据库账号要有建立临时表的权限;
2.在同一条sql中,不能关联2次相同的临时表,不然,就会报如下错误;

RROR 1137: Can’t reopen table: ‘temp_table’

3.临时表在建立连接时可见,关闭时会清除空间,删除临时表;
4.show tables 不会列出临时表;


原文链接:https://blog.csdn.net/u010265663/article/details/50210867

posted @ 2021-03-18 10:54  魏三斗  阅读(1135)  评论(0编辑  收藏  举报