旧式 Oracle 外连接语法 - 为什么在左外连接中找到等号右侧的 (+)?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22678643/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Old Style Oracle Outer Join Syntax - Why locate the (+) on the right side of the equals sign in a Left Outer join?
提问by Matthew Moisen
I always tell new people that an easy way to remember the old-style, Oracle outer-join syntax is that
我总是告诉新人,记住旧式 Oracle 外连接语法的一种简单方法是
the (+) sign is on opposite side of where you think it should be.
(+) 符号位于您认为它应该位于的位置的对面。
Left join:
左连接:
select * from foo, bar
where foo.id = bar.id(+)
Right join:
正确加入:
select * from foo, bar
where foo.id(+) = bar.id
I'm sure I learned this in college, but what is the purpose of having the (+) sign on either side? Does it simply indicate "even those rows on the other side that don't match on this side"? but that would seem too complicated. What was the purpose of choosing "(+)" and putting it on the side where no match was made?
我确定我在大学里学过这个,但是在两边都有 (+) 号的目的是什么?它是否只是表示“即使是另一侧的那些行与这一侧不匹配”?但这似乎太复杂了。选择“(+)”并放在没有匹配的一侧的目的是什么?
回答by Justin Cave
The (+)
identifies the table that is being outer joined to. The way I was taught, the (+)
indicated the table that would have missing rows for which new NULL
rows had to be added.
的(+)
标识正在外表接合。我被教导的方式,(+)
表明表中将缺少NULL
必须添加新行的行。
If you look at the alternate left outer join syntaxesthat various databases supported before LEFT OUTER JOIN
became part of the ANSI standard, the proprietary operator was generally applied to the table that was "missing" rows. DB2 also supports the (+)
operator for outer joinsin the same way that Oracle does.
如果您查看在成为 ANSI 标准的一部分之前各种数据库支持的备用左外连接语法,LEFT OUTER JOIN
专有运算符通常应用于“丢失”行的表。 DB2 还(+)
以与 Oracle 相同的方式支持外连接运算符。