1. <ul id="0c1fb"></ul>

      <noscript id="0c1fb"><video id="0c1fb"></video></noscript>
      <noscript id="0c1fb"><listing id="0c1fb"><thead id="0c1fb"></thead></listing></noscript>

      99热在线精品一区二区三区_国产伦精品一区二区三区女破破_亚洲一区二区三区无码_精品国产欧美日韩另类一区

      RELATEED CONSULTING
      相關(guān)咨詢
      選擇下列產(chǎn)品馬上在線溝通
      服務(wù)時間:8:30-17:00
      你可能遇到了下面的問題
      關(guān)閉右側(cè)工具欄

      新聞中心

      這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
      全外連接的unionall改寫方法是什么樣的

      這篇文章給大家介紹全外連接的union all改寫方法是什么樣的,內(nèi)容非常詳細,感興趣的小伙伴們可以參考借鑒,希望對大家能有所幫助。

      成都創(chuàng)新互聯(lián)-專業(yè)網(wǎng)站定制、快速模板網(wǎng)站建設(shè)、高性價比古城網(wǎng)站開發(fā)、企業(yè)建站全套包干低至880元,成熟完善的模板庫,直接使用。一站式古城網(wǎng)站制作公司更省心,省錢,快速模板網(wǎng)站建設(shè)找我們,業(yè)務(wù)覆蓋古城地區(qū)。費用合理售后完善,10余年實體公司更值得信賴。

      對于SQL中的連接操作在實現(xiàn)業(yè)務(wù)需求的時候比較方便和高效,這里針對“全外連接”展示一下在Oracle中的幾種寫法。
      每種寫法因人而異,以滿足需求為目的。

      有關(guān)內(nèi)連接,左連接和右連接的簡單演示請參考:《【實驗】內(nèi)連接,左連接,右連接,全外連接》http://space.itpub.net/519536/viewspace-563019

      1.創(chuàng)建實驗表并初始化實驗數(shù)據(jù)
      SQL> create table a (a number(1),b number(1),c number(1));
      SQL> create table b (a number(1),d number(1),e number(1));
      SQL> insert into a values(1,1,1);
      SQL> insert into a values(2,2,2);
      SQL> insert into a values(3,3,3);
      SQL> insert into b values(1,4,4);
      SQL> insert into b values(2,5,5);
      SQL> insert into b values(4,6,6);
      SQL> commit;

      2.查看一下初始化數(shù)據(jù)內(nèi)容
      sec@ora10g> select * from a;

               A          B          C
      ---------- ---------- ----------
               1          1          1
               2          2          2
               3          3          3

      sec@ora10g> select * from b;

               A          D          E
      ---------- ---------- ----------
               1          4          4
               2          5          5
               4          6          6

      3.第一種寫法,這也是標準SQL的寫法。功能明確,不過理解有點小障礙。
      sec@ora10g> select * from a full outer join b on a.a = b.a;

               A          B          C          A          D          E
      ---------- ---------- ---------- ---------- ---------- ----------
               1          1          1          1          4          4
               2          2          2          2          5          5
               3          3          3
                                                4          6          6

      4.第二種寫法
      思路:“a到b的全外連接”=“a到b的內(nèi)連接” + “b到a的反連接” + “a到b的反連接”。
      sec@ora10g> select *
        2    from a, b
        3   where a.a = b.a
        4  union all
        5  select *
        6    from a, b
        7   where a.a(+) = b.a
        8     and a.a is null
        9  union all
       10  select *
       11    from a, b
       12  where a.a = b.a(+)
       13     and b.a is null
       14  /

               A          B          C          A          D          E
      ---------- ---------- ---------- ---------- ---------- ----------
               1          1          1          1          4          4
               2          2          2          2          5          5
                                                4          6          6
               3          3          3

      5.第三種寫法
      思路:“a到b的全外連接”=“b到a的外部連接” + “a到b的反連接”。
      sec@ora10g> select *
        2    from a, b
        3   where a.a(+) = b.a
        4  union all
        5  select *
        6    from a, b
        7   where a.a = b.a(+)
        8     and b.a is null
        9  /

               A          B          C          A          D          E
      ---------- ---------- ---------- ---------- ---------- ----------
               1          1          1          1          4          4
               2          2          2          2          5          5
                                                4          6          6
               3          3          3


      6.小結(jié)
      注意,改寫方法中的“union all”也可以修改為“union”,之所以上面改寫方法中我們使用union all,原因是出于性能方便的考慮,union all的執(zhí)行效率遠大于union操作。

      這里展示的是一種轉(zhuǎn)換思路,可一看了之。

      關(guān)于全外連接的union all改寫方法是什么樣的就分享到這里了,希望以上內(nèi)容可以對大家有一定的幫助,可以學(xué)到更多知識。如果覺得文章不錯,可以把它分享出去讓更多的人看到。


      分享名稱:全外連接的unionall改寫方法是什么樣的
      標題來源:http://www.ef60e0e.cn/article/iedijh.html
      99热在线精品一区二区三区_国产伦精品一区二区三区女破破_亚洲一区二区三区无码_精品国产欧美日韩另类一区
      1. <ul id="0c1fb"></ul>

        <noscript id="0c1fb"><video id="0c1fb"></video></noscript>
        <noscript id="0c1fb"><listing id="0c1fb"><thead id="0c1fb"></thead></listing></noscript>

        铜陵市| 九寨沟县| 武隆县| 革吉县| 茌平县| 沙田区| 丘北县| 栾川县| 萝北县| 南平市| 石景山区| 平塘县| 白玉县| 九江市| 大埔区| 麻江县| 开平市| 临夏县| 新安县| 德昌县| 新化县| 宾川县| 顺平县| 太仓市| 油尖旺区| 昆明市| 辽中县| 临沧市| 桂平市| 镇沅| 惠水县| 冷水江市| 兖州市| 奈曼旗| 绥芬河市| 沂源县| 舟山市| 治多县| 澄江县| 建湖县| 阿拉善盟|