What's the difference between using oracle's plus notation (+)
over the ansi standard join
notation?
Is there a difference in performance?
Is the plus notation deprecated?
What's the difference between using oracle's plus notation (+)
over the ansi standard join
notation?
Is there a difference in performance?
Is the plus notation deprecated?
I use (+) notation, because almost all of the Oracle Apps r12 related queries are based on that. I've not seen a single SQL query with a standard "join" expression in Oracle APPS queries(even the ones provided by Oracle itself). If you don't believe me, simply google any Oracle apps related information. For example: Fixed assets related queries
AFAIK, the
(+)
notation is only present for backwards compatibility because Oracle debuted it before the ANSI standard for joins was put in place. It's specific to Oracle and you should avoid using it in new code when there's an equivalent standards-compliant version available.Edit: It seems there are differences between the two, and the
(+)
notation has restrictions that the ANSI join syntax does not have. Oracle themselves recommend that you not use the(+)
notation. Full description here in the Oracle® Database SQL Language Reference 11g Release 1 (11.1):Oracle recommends that you use the
FROM
clauseOUTER JOIN
syntax rather than the Oracle join operator. Outer join queries that use the Oracle join operator(+)
are subject to the following rules and restrictions, which do not apply to theFROM
clauseOUTER JOIN
syntax:(+)
operator in a query block that also containsFROM
clause join syntax.(+)
operator can appear only in theWHERE
clause or, in the context of left-correlation (when specifying theTABLE
clause) in theFROM
clause, and can be applied only to a column of a table or view.If A and B are joined by multiple join conditions, then you must use the
(+)
operator in all of these conditions. If you do not, then Oracle Database will return only the rows resulting from a simple join, but without a warning or error to advise you that you do not have the results of an outer join.The
(+)
operator does not produce an outer join if you specify one table in the outer query and the other table in an inner query.You cannot use the
(+)
operator to outer-join a table to itself, although self joins are valid.For example, the following statement is not valid:
However, the following self join is valid:
The
(+)
operator can be applied only to a column, not to an arbitrary expression. However, an arbitrary expression can contain one or more columns marked with the(+)
operator.A
WHERE
condition containing the(+)
operator cannot be combined with another condition using theOR
logical operator.A
WHERE
condition cannot use theIN
comparison condition to compare a column marked with the(+)
operator with an expression.If the
WHERE
clause contains a condition that compares a column from table B with a constant, then the(+)
operator must be applied to the column so that Oracle returns the rows from table A for which it has generated nulls for this column. Otherwise Oracle returns only the results of a simple join.In a query that performs outer joins of more than two pairs of tables, a single table can be the null-generated table for only one other table. For this reason, you cannot apply the
(+)
operator to columns of B in the join condition for A and B and the join condition for B and C. Refer toSELECT
for the syntax for an outer join.Oracle (+) notation is only used in Oracle, which is vendor specific. And,ANSI standared Join notation can be used in any RDBMS (like Sql Server,MySql etc.). Otherwise,there is no difference between Oracle (+) notation and ANSI standared Join notation.
If you are using the ANSI standared Join notation in your Sql Query, you can use the same query in any RDBMS. And, if you are porting your database from Oracle to any Other RDBMS in that condition you have to use ANSI Syntax.
One of the good reasons to use ANSI syntax over the old Oracle join syntax is that, there are nil chances of accidentally creating a cartesian product. With more number of tables, there is a chance to miss an implicit join with older Oracle join syntax, however, with ANSI syntax you cannot miss any join as you must explicitly mention them.
Difference between Oracle outer join syntax and the ANSI/ISO Syntax.
LEFT OUTER JOIN -
RIGHT OUTER JOIN -
FULL OUTER JOIN -
Before the native support of hash full outerjoin in 11gR1, Oracle would internally convert the FULL OUTER JOIN the following way -
Have a look at this.
The notation is still supported as of Oracle 10 (and I believe 11). It's use is considered "old fashioned", and also is not as database portable as the ANSI JOIN syntax. It's also considered much less readable, although if you come from the + background getting used to ANSI JOIN can take a little time. The important thing to know before hurling brickbats at Oracle is that they developed their + syntax before the ANSI committee had completed the definitions for the joins.
There is no performance difference; they are expressing the same thing.
Edit: By "not as portable" I should have said "only supported in Oracle SQL"