Use of (+) in Oracle


(+) Introduction

(+) is a special usage in oracle, (+) means outer connection, and it is always placed on the side of the non-main table.

  • The (+) operator can only appear in the WHERE clause and cannot be used with the OUTER JOIN syntax
  • When using the (+) operator to perform an outer join, if multiple conditions are included in the WHERE clause, the (+) operator must be included in all conditions
  • The (+) operator only works on columns, not on expressions
  • The (+) operator cannot be used with the OR and IN operators
  • The (+) operator can only be used to implement left outer joins and right outer joins, not for full outer joins

left outer join

left condition = right condition (+)

SELECT
	A.a,
	B.a 
FROM
	A,
	B 
WHERE
	A.b = B.b(+)

Equivalent to

SELECT
	A.a,
	B.a 
FROM
	A
	LEFT JOIN B ON A.b = B.b

right outer join

right condition = left condition (+)

SELECT
	A.a,
	B.a 
FROM
	A,
	B 
WHERE
	B.b = A.b(+)

Equivalent to

SELECT
	A.a,
	B.a 
FROM
	A
	RIGHT JOIN B ON A.b = B.b

Guess you like

Origin blog.csdn.net/JokerLJG/article/details/129962049