Differences between Natural Join and Inner Join

8

What characteristics differentiate a query performed using Natural Join from another with the use of Inner Join ? Is there any performance related question or any other condition that leads me to choose one over the other?

For the example below, we would have the following queries:

select livro.nome_livro, editora.nome_editora from livro natural join editora

or

select livro.nome_livro, editora.nome_editora from livro
inner join editora on editora.codigo_editora = livro.codigo_editora

    
asked by anonymous 21.03.2015 / 15:53

1 answer

10

NATURAL JOIN is only a facilitator. It is not faster or does nothing better, it only allows a shorter syntax if the join is simple. Your example illustrates this well. Both do exactly the same thing but the first one is easier to write.

The name is so because this is the most natural way to make a INNER JOIN simple.

As you can see, it is not possible to produce results with more complex expressions using the natural form.

If * is used to get the fields in the tables with NATURAL JOIN the columns of the same name will not be shown repeated in the result.

Wikipedia article .

    
21.03.2015 / 16:04