当前位置:网站首页>[SQL optimization] the difference between with as and temporary tables
[SQL optimization] the difference between with as and temporary tables
2022-07-01 19:36:00 【Tanyue Jianzhi Dachang】
with as and The difference between temporary tables
1.with as
with as Just treat the subquery statement as a table , But the real data is not inserted into the database , Its advantage is to increase the readability and maintenance of the code .
with tmp_01 as (
select *
from table)
select *
from tmp_01;
2. A temporary table
The data of the temporary table needs to be inserted into the database , So it is generally used for making statements , After inserting data, you need to delete the temporary table .
drop table if exists tmp_01;
create table if not exists tmp_01 as
select *
from table;
select *
from tmp_01;
3. Operational efficiency
use with as , In fact, there is no difference in efficiency with direct sub query ;
The temporary table is similar to the permanent table , The data is really running into the database , Equivalent to the second direct correlation is a small table , Query efficiency is greatly improved .
4. Application scenarios
Temporary table applies to : There are many complex associated sub table queries .
with as Apply to : To increase code readability , And there are not many complex associated sub queries .
边栏推荐
- 703. The k-th element in the data flow
- [go ~ 0 to 1] day 4 June 30 defer, structure, method
- 论文泛读【FiLM: Visual Reasoning with a General Conditioning Layer】
- MATLAB中subplot函数的使用
- Intensive cultivation of channels for joint development Fuxin and Weishi Jiajie held a new product training conference
- 【To .NET】C#集合类源码解析
- [6.24-7.1] review of wonderful technical blog posts in the writing community
- H264 encoding profile & level control
- Introduction and installation of crunch, and making password dictionary with crunch
- 如何正确使用Vertx操作Redis(3.9.4带源码分析)
猜你喜欢

Facebook聊单,SaleSmartly有妙招!

Methods of finding various limits
使用环信提供的uni-app Demo,快速实现一对一单聊

Flutter 实战-快速实现音视频通话应用

见证时代!“人玑协同 未来已来”2022弘玑生态伙伴大会开启直播预约
![[pytorch record] automatic hybrid accuracy training torch cuda. amp](/img/a5/cf1eb2801380cf2887dfd532d3eb1e.jpg)
[pytorch record] automatic hybrid accuracy training torch cuda. amp

Les canaux de culture intensive s'efforcent de développer Fu Xin et Wei Shi jiajie pour organiser une conférence de formation sur les nouveaux produits

Native JS creates a calendar - supports mouse wheel scrolling to select months - and can be ported to any framework
Use the uni app demo provided by Huanxin to quickly realize one-on-one chat

商业智能BI开发和报表开发有什么本质区别?
随机推荐
Introduction to relevant processes and functions of wechat official account development
DTD建模
Ffmpeg avframe to cv:: mat
IPv4地址、子网掩码、网关
Basic knowledge of audio coding and decoding
【org.slf4j.Logger中info()方法】
A brief understanding of white box encryption technology
Interview questions for audio and video positions in Dachang -- today's headline
How to redraw the header of CListCtrl in MFC
The difference between indexof and includes
Opencv video quality detection -- sharpness detection
Introduction and installation of crunch, and making password dictionary with crunch
English语法_形容词/副词3级 -注意事项
Boost the development of digital economy and consolidate the base of digital talents - the digital talent competition was successfully held in Kunming
ffmpeg 音频相关命令
Solidity - 算术运算的截断模式(unchecked)与检查模式(checked)- 0.8.0新特性
白盒加密技术浅理解
XML syntax, constraints
Implement a Prometheus exporter
CMU AI PhD 第一年总结