当前位置:网站首页>Execution of SQL statement
Execution of SQL statement
2020-11-08 21:14:00 【Let me love you】
SQL, Script query language , The order in which the code is processed is not in the order of the scripting language , This is the most obvious feature different from other programming languages .
SQL Language is common, such as ,Mysql,HiveQL,Oracle etc. , Although there are some grammatical differences , But they're interpreting query scripts , In particular, the execution sequence of parsing statements has commonness . If you decompose a scripting language into a series of statements , So what is the order of execution of these statements ?
Select Statement execution order
select
The execution order of the query statement , It can be seen that the first execution is FROM
Clause , Finally, execute ORDER BY
Execution order :
(1) FROM
(2) ON
(3) JOIN
(4) WHERE
(5) GROUP BY
(6) WITH {CUBE | ROLLUP}
(7) HAVING
(8) SELECT
(9) DISTINCT
(10) ORDER BY
(11) LIMIT
7 SELECT ( Query content )
1 FROM <left table> ( Query the main table )
3 <join type> JOIN <right table> ( Associated table )
2 ON <join condition> ( The condition of two tables Association )
4 WHERE ( Conditions for filtering query results )
5 GROUP BY ( Grouping conditions )
6 HAVING ( Conditions for filtering groups )
8 ORDER BY ( Sorting conditions )
# The preceding number is the order in which the actual program is executed ,
# To develop a good code format , The empty line, the empty line , It should be capitalized ( Try to keep the words in uppercase for database operations , Keep the contents of library, table and column in lowercase as much as possible )
A brief introduction to the above logical sequence
Each of the above steps produces a virtual table , The virtual table is used as input for the next step . Only the table generated in the last step is returned to the caller .
- FROM: Yes FROM The first two tables in the clause perform the cartesian product ( Cross connection ), Generate virtual tables VT1, Select a relatively small table as the base table .
- ON: Yes VT1 application ON Filter , Only those that are true are inserted VT2.
- OUTER (JOIN): If you specify OUTER JOIN( be relative to CROSS JOIN or INNER JOIN), No matching rows were found in the reservation table to be added as external rows to VT2, Generate TV3.
- WHERE: Yes VT3 application WHERE Filter , Only the emissary true Rows of VT4.
- GROUP BY: Press GROUP BY Column pairs in clause VT4 Group the rows in , Generate VT5.
- CUTE|ROLLUP: Insert the supergroup into VT5, Generate VT6.
- HAVING: Yes VT6 application HAVING Filter , Only the emissary true The group inserted into VT7.
- SELECT: Handle SELECT list , produce VT8.
- DISTINCT: Repeat lines from VT8 Delete in , obtain VT9.
- ORDER BY: take VT9 The lines in the press ORDER BY Column list order in the clause , Generate a cursor (VC10).
- LIMIT(TOP): from VC10 Selects the rows at the beginning of , To generate table VT11, And return it to the caller .
版权声明
本文为[Let me love you]所创,转载请带上原文链接,感谢
边栏推荐
- CMS garbage collector
- Dynamic relu: Microsoft's refreshing device may be the best relu improvement | ECCV 2020
- 给大家介绍下,这是我的流程图软件 —— draw.io
- Solve the problem that the value of new date() of JS in IE and Firefox is invalid date and Nan Nan
- 解决IE、firefox浏览器下JS的new Date()的值为Invalid Date、NaN-NaN的问题
- 如何将 PyTorch Lightning 模型部署到生产中
- Fiddler无法正常抓取谷歌等浏览器的请求_解决方案
- Summary of interface test case ideas
- Dynamic ReLU:微软推出提点神器,可能是最好的ReLU改进 | ECCV 2020
- The interface testing tool eolinker makes post request
猜你喜欢
进程 线程 协程
动态规划设计:最大子数组
To introduce to you, this is my flow chart software—— draw.io
Fiddler无法正常抓取谷歌等浏览器的请求_解决方案
为什么需要使用API管理平台
解决IE、firefox浏览器下JS的new Date()的值为Invalid Date、NaN-NaN的问题
200 programmers interview experience, all here
程序员都应该知道的URI,一文帮你全面了解
Iptables from introduction to mastery
新手入坑指南:工作原因“重启”Deepin系统,发现真的香啊
随机推荐
装饰器(一)
What are the basic requirements for big data posts?
.NET Core 跨平台资源监控库及 dotnet tool 小工具
在Python中创建文字云或标签云
解决IE、firefox浏览器下JS的new Date()的值为Invalid Date、NaN-NaN的问题
选择排序
第一部分——第2章指针操作
线程池运用不当的一次线上事故
Dynamic relu: Microsoft's refreshing device may be the best relu improvement | ECCV 2020
Creating a text cloud or label cloud in Python
Flink的DataSource三部曲之三:自定义
程序员都应该知道的URI,一文帮你全面了解
经典动态规划:最长公共子序列
选择API管理平台之前要考虑的5个因素
MongoDB数据库
给大家介绍下,这是我的流程图软件 —— draw.io
接口测试工具Eolinker进行post请求
Five factors to consider before choosing API management platform
Python的特性与搭建环境
国内三大云数据库测试对比