时间:2021-07-01 10:21:17 帮助过:3人阅读
sql格式
[SQL 语句 1]
UNION(all)
[SQL 语句 2]
union 不带all,隐式带distinct,并在结果上应用distinct(删除重复行)
union all 是没有删除重复行的union。
ecxept 返回在第一个输入中出现,第二输入没有出现的不重复行。
返回在employees出现的城市,但是没有在customers出现的
返回在俩个输入中都出现的行(支持隐含distinct形式)
- <span style="color: #008080;">1</span> <span style="color: #0000ff;">SELECT</span> <span style="color: #800000; font-weight: bold;">6</span> <span style="color: #0000ff;">AS</span><span style="color: #000000;"> age
- </span><span style="color: #008080;">2</span> <span style="color: #0000ff;">INTERSECT</span>
- <span style="color: #008080;">3</span> <span style="color: #0000ff;">SELECT</span> <span style="color: #800000; font-weight: bold;">6</span> <span style="color: #0000ff;">AS</span> age
性能分析,可以看出顶部输入扫描和底部输入扫描匹配开销最大。
INTERSECT集合运算比其他集合运算的优先级更高,最先执行INTERSECT,但是可以依靠圆括号来控制逻辑顺序。
T-Sql之集合
标签:strong mes tom 需要 分享图片 str 转换 优先 分析