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

來源:互聯網
上載者:User

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;

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.