Oracle中的聯集查詢-自然串連/外串連/內串連

來源:互聯網
上載者:User

自然串連
 
select *
 
from r1 natural [inner] join r2 natural [inner] join r3
 
where P;
 
 
 
select A1,A2
 
from r1
 
natural [inner] join
 r2,r3 where r2.A=r3.B;
 
自然串連中,匹配關係(relation,表)中屬性(attribute,列)的屬性名稱相同的所有列,只保留所有屬性名稱都相同的元組(tuple,行),並顯示出來;列出屬性的順序:首先列出兩個關係中相同的屬性,然後列出那些只存在在第一個關係中的屬性,最後輸出只存在第二個關係中的屬性。
 
為了發揚自然串連的優點,同時避免不必要的相等屬性帶來的危險,SQL允許使用者來指定需要那些列相等:
 
select *
 
from r1 [inner] join r2 using (attri_name);

注意事項:
 
1、如果在使用using關鍵字時,而且select的結果清單項中包含了using關鍵字所指明的那個關鍵字,那麼請不要在select的結果清單項中對該關鍵字指明它屬於哪個表。
 
2、using中僅能使用一個列名。
 
3、natural join關鍵字和using關鍵字是互斥的,也就是說不能同時出現。

  • 1
  • 2
  • 下一頁

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.