Oracle中關於並集/交集/差集的運算

1.並集的運算
select name from test1
  union [all]
select name from test2;
使用union時,默認將對結果進行排序,union all則不進行排序操作,所以會消耗更少的資源;然而,union all將不進行去重的操作~
 
2.交集的運算
select name from test1
  intersect
select name from test2;
    Oracle不支持Intersect all關鍵字!
 
3.差的運算
select name from test1
  minus
select name from test2;
    Oracle中差的運算不同於SQL標準,在SQL標準中,我們使用以下函數進行差運算
select name from test1
  except [all]
select name from test2;
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章