Oracle學習筆記 外連線 的用法

2022-09-17 13:30:22 字數 986 閱讀 4266

oracle中常用 left join 和 right join 來進行外連線,同時,oracle也支援 (+) 的特殊用法,也是表示外連線,並且總是放在非主表的一方。

例如:左外連線:

select

a.id,b.id

from

a left

join

b on a.id = b.id;

等價於:

select

a.id, b.id

from

a,bwhere a.id = b.id(+);

同理,右外連線

select

a.id,b.id

from

a right

join

b on a.id = b.id;

等價於:

select

a.id, b.id

from

a,bwhere a.id(+) = b.id;

注意:

1.(+)操作符只能出現在where子句中,並且不能與outer join語法同時使用。

2.當使用(+)操作符執行外連線時,如果在where子句中包含有多個條件,則必須在所有條件中都包含(+)操作符。

3.(+)操作符只適用於列,而不能用在表示式上。

4.(+)操作符不能與or和in操作符一起使用。

5.(+)操作符只能用於實現左外連線和右外連線,而不能用於實現完全外連線。

left/right join 和 (+) 的區別:

1.效率上沒區別

2.left join 可讀性高、功能更全面、通用性強、而且是新標準

3.建議使用left join

end 2018-12-18 22:52:22

Oracle學習 外連線

對於外連線 oracle中可以使用 來表示,9i可以使用left right full outer join 外部連線 按其在 的左邊或右邊分右連線和左連線.若不帶 運算子的表中的乙個行不直接匹配於帶 預算符的表中的任何行,則前者的行與後者中的乙個空行相匹配並被返回.若二者均不帶 則二者中無法匹配的...

Oracle外連線,左外連線,右外連線,內連線簡析

內連線即普通等值連線 select e.ename,e.job,e.sal,d.dname from emp e inner join dept d on e.deptno d.deptno where e.sal 2000 select e.ename e.job,e.sal d.dname fr...

oracle內連線 外連線

表testa,testb,testc,各有a,b兩列 a b001 10a002 20a a b 001 10b 003 30b a b001 10c004 40c 連線分為兩種 內連線與外連線。a 內連線 內連線,即最常見的等值連線,例 select fromtesta,testb wherete...