一般在数据量比较大的查询中,用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

相关文章:

  • 2021-08-02
  • 2022-02-21
  • 2022-12-23
  • 2021-11-04
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-09-01
  • 2021-05-31
  • 2021-11-05
  • 2021-10-21
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案