SQL SERVER - T-SQL Logical Processing Steps

来源:互联网 发布:58自动发帖软件 编辑:程序博客网 时间:2024/06/06 01:49


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了。原因待分析,忘记得太快了,知识看来要定期回顾。