SQL SERVER - T-SQL Logical Processing Steps

本文深入探讨了SQL与其他编程语言在代码执行顺序上的显著差异。详细介绍了SQL查询的处理流程,从FROM子句开始到最后的ORDER BY子句结束,并解释了每个步骤如何生成一个虚拟表作为后续步骤的输入。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >



The first noticeable aspect of SQL that is different than other programming languages is the order in which the code is processed. In most programming languages, the code is processed in the order in which it is written. In SQL, the first clause that is processed is the FROM clause, while the SELECT clause, which appears first, is processed almost last.

Each step generates a virtual table that is used as the input to the following step. These virtual tables are not available to the caller (client application or outer query). Only the table generated by the final step is returned to the caller. If a certain clause is not specified in a query, the corresponding step is simply skipped. Following is a brief description of the different logical steps applied in both SQL Server 2000 and SQL Server 2005.


(n)是指逻辑执行步骤。每一步都是为下一步提供了一个虚拟的table,这个table是应用程序或者用户无法取到的。

order by放在了最后第二步,如果使用top字句,那么sub query就可以使用order by了。原因待分析,忘记得太快了,知识看来要定期回顾。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值