sql - Left Outer Join using + sign in Oracle 11g -
can 1 tell me whether below 2 queries example of left outer join or right outer join??
table part: name null? type part_id not null varchar2(4) supplier_id varchar2(4) part_id supplier_id p1 s1 p2 s2 p3 p4 table supplier: name null? type supplier_id not null varchar2(4) supplier_name not null varchar2(20) supplier_id supplier_name s1 supplier#1 s2 supplier#2 s3 supplier#3 display parts irrespective of whether supplier supplies them or not:
select p.part_id, s.supplier_name part p, supplier s p.supplier_id = s.supplier_id (+) select p.part_id, s.supplier_name part p, supplier s s.supplier_id (+) = p.supplier_id
thanks!
tablea left outer join tableb equivalent tableb right outer join table a.
in oracle, (+) denotes "optional" table in join. in first query, it's p left outer join s. in second query, it's s right outer join p. they're functionally equivalent.
in terminology, right or left specify side of join has record, , other side might null. in p left outer join s, p have record because it's on left, s null.
see this example java2s.com additional explanation.
to clarify, guess i'm saying terminology doesn't matter, it's there visualize. matters understand concept of how works.
right vs left
i've seen confusion matters in determining right vs left in implicit join syntax.
left outer join
select * a, b a.column = b.column(+) right outer join
select * a, b b.column(+) = a.column all did swap sides of terms in clause, they're still functionally equivalent. (see higher in answer more info that.) placement of (+) determines right or left. (specifically, if (+) on right, it's left join. if (+) on left, it's right join.)
types of join
the 2 styles of join implicit joins , explicit joins. different styles of writing joins, functionally equivalent.
see this question.
implicit joins list tables together. join conditions specified in clause.
implicit join
select * a, b a.column = b.column(+) explicit joins associate join conditions specific table's inclusion instead of in clause.
explicit join
select * left outer join b on a.column = b.column these implicit joins can more difficult read , comprehend, , have few limitations since join conditions mixed in other conditions. such, implicit joins recommended against in favor of explicit syntax.
Comments
Post a Comment