I am reading about NATURAL shorthand form for SQL joins and I see some traps:
A NATURAL JOIN is a JOIN operation that creates an implicit join clause for you based on the common columns in the two tables being joined. Common columns are columns that have the same name in both tables. A NATURAL JOIN can be an INNER join, a LEFT OUTER join, or a RIGHT OUTER join. The default is INNER join.
To be modifiable, a join view must not contain any of the following: Hierarchical query clauses, such as START WITH or CONNECT BY. GROUP BY or HAVING clauses. Set operations, such as UNION, UNION ALL, INTERSECT, MINUS.
The join clause is used to combine tables based on a common column and a join condition. A natural join is a type of join that combines tables based on columns with the same name and type.
There are four main types of JOINs in SQL: INNER JOIN, OUTER JOIN, CROSS JOIN, and SELF JOIN.
NATURAL JOIN
syntax is anti-pattern:
Because of this, I don't recommend the syntax in any environment.
I also don't recommend mixing syntax (IE: using both NATURAL JOIN
and explicit INNER/OUTER JOIN syntax) - keep a consistent codebase format.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With