菜鸟学TSQLSQL2005读书笔记1

第一章:逻辑查询处理 Logical Query Processing

    1.什么是T-SQL?

    T-SQL 是SQL的Microsoft SQL Server 方言----Transcact-SQL,它遵循 ANSI 标准。

    2.逻辑查询处理中的各个阶段

        

8select (9) distinct (11) <TOP_spicification> <select_list>1from <left_table>

     (3)  <jiong_type> join <right_table>

     (2)  on <join_condition>

     (4)  where <where_condition>

     (5)  group by <group_by_list>

     (6)  with {cube | rollup }

     (7)  having <aving_condition>

     (10) order by <order_by_list>

   概述:

1.From :对From中的前两个表执行笛卡尔积(Cartesian product)(交叉联接),生成虚拟表 VT1;

2.On : 对VT1 应用 on 筛选器 。只有使<join_condition>为真的行才能被插入VT2;

3.OUTER(JOIN) :如果指定了outer join(相对于cross join 或 inner join),保留表(preserved table)中未找到匹配的行将作为外部行添加到VT2,生成T3,如果From子句包括两个以上的表,则对上一联接生成的结果表和下一个表重复执行步骤1到3,知道处理完所有的表为止。

4.对VT3应用where筛选器,只有使<where_condition>为真的行才被插入VT4。

5.Group By :按Group By 子句中的列列表对VT4中的行进行分组,生成VT5。

6.Cube|rollup:把超组(supergroup)插入VT5,生成VT6。

   

原文地址:https://www.cnblogs.com/shenfengok/p/2566034.html