Oracle Natural Joins and Count(1)

前端 未结 4 373
长发绾君心
长发绾君心 2021-01-14 01:55

Does anyone know why in Oracle 11g when you do a Count(1) with more than one natural join it does a cartesian join and throws the count way off?

Such as

<         


        
相关标签:
4条回答
  • 2021-01-14 02:13

    Just noticed you used 2 natural joins... From the documentation you can only use a natural join on 2 tables Natural_Join

    0 讨论(0)
  • 2021-01-14 02:14

    If it happens exactly as you say then it must be an optimiser bug, you should report it to Oracle.

    0 讨论(0)
  • 2021-01-14 02:26

    My advice would be to NOT use NATURAL JOIN. Explicitly define your join conditions to avoid confusion and "hidden bugs". Here is the official NATURAL JOIN Oracle documentation and more discussion about this subject.

    0 讨论(0)
  • 2021-01-14 02:27

    you should try a count(*)

    There is a difference between the two.
    count(1) signifies count rows where 1 is not null
    count(*) signifies count the rows

    0 讨论(0)
提交回复
热议问题