NATURAL JOIN can join tables with no common column names

It is a well-known fact that NATURAL JOIN joins the two tables using all columns with the same name. But if two tables have no columns with the same name, then cross product is produced.

Let’s have a look for these two tables – they don’t have any columns with the same name

 

Now let’s see how many rows will be produced by CROSS JOIN. As we can see below the number of rows is 198

Now let’s see how many rows will be produced by NATURAL JOIN. As we can see below the number of rows is 198 too

It is happening because NATURAL JOIN would work exactly as CROSS JOIN in case when two tables would not have any same column names.

Who would have thought? But it is standard Oracle behavior. You should remember it because this is a guaranteed situation on the exam.

 

Leave a comment

Your email address will not be published. Required fields are marked *