注意:我不是要求您告诉我"使用显式连接",而是寻找Oracle官方立场,如果有任何关于该主题的话.
从Oracle数据库文档(也出现在9i和11g文档中):
Oracle建议您使用
FROM子句OUTER JOIN语法而不是Oracle连接运算符.使用Oracle join运算符的外连接查询(+)受以下规则和限制的约束[...]
换句话说,Oracle建议更喜欢这两种形式中的第一种:
FROM a LEFT JOIN b ON b.x = a.x
vs
FROM a, b WHERE b.x(+) = a.x
Run Code Online (Sandbox Code Playgroud)
但是,我从来没有在任何Oracle文档中找到一个建议,最好使用这两种形式之一:
FROM a INNER JOIN b ON b.x = a.x
vs
FROM a, b WHERE b.x = a.x
Run Code Online (Sandbox Code Playgroud)
我错过了一段吗?
Tre*_*rth 10
有关ANSI连接语法问题的Oracle支持站点有很多说明,其中有一些建议使用oracle语法的变通方法.
错误的结果5188321(无行)或ORA-1445来自ANSI外连接
Versions affected: Versions >= 9.2.0.1 but < 11
Description
Wrong results or an ORA-1445 can be returned with a query involving a
very large select list count when ANSI OUTER JOIN syntax is used.
Workaround
Use native oracle outer join syntax
or
reduce the select list count.
Run Code Online (Sandbox Code Playgroud)
错误5368296 ANSI连接SQL可能不会为不明确的列报告ORA-918
Versions affected: Versions < 11
Description
****
Note: This fix introduces the problem described in bug 7318276
One off fixes for that bug address the issue here also.
****
ORA-918 is not reported for an ambiguous column in a query
involving an ANSI join of more than 2 tables/objects.
eg:
-- 2 table join, returns ORA-918
SELECT empno
FROM emp a JOIN emp b on a.empno = b.empno;
-- 3 table join does not report ORA-918 when it should ...
SELECT empno
FROM emp a JOIN emp b on a.empno = b.empno
JOIN emp c on a.empno = c.empno;
Run Code Online (Sandbox Code Playgroud)
错误7670135编译ANSI连接的长解析时间
Versions affected: Versions BELOW 11.2
Description
A query having ANSI join(s) may take noticeable time during query compilation,
especially if the query includes an NVL() function.
Workaround:
Use ORACLE join instead of ANSI join
Run Code Online (Sandbox Code Playgroud)
来自Oracle Press - Oracle OCP 11g一体化考试指南
并且来自asktom(谁是非承诺)
Historically there have been bugs related to ANSI syntax, in fact even the
10.2.0.4 projected issues list includes 10 bugs/issues related to ANSI syntax.
In the past I've encountered some of these bugs myself, and have continued to use
and advocate the "traditional" Oracle style.
I'd like to know if you feel that the implementation of ANSI syntax is now equally
robust compared to the traditional syntax.
Followup February 19, 2008 - 5pm Central time zone:
unfortunately, there are bugs in non-ansi joins too, probably more than 10 in fact.
I personally do not use the new syntax (except in the rare case of a full outer join,
a truly rare beast to encounter). I have no comment on it really.
Run Code Online (Sandbox Code Playgroud)
另请参阅前面关于同一主题的问题 Oracle的加号(+)表示法与ansi JOIN表示法之间的区别?
我也在一份文件中发现了这个陈述,但没有提到它来自哪里
"从Oracle 9i开始,Oracle建议SQL开发人员使用ANSI连接语法而不是Oracle专有(+)语法.这个建议有几个原因,包括:
•更容易隔离和读取(不含混合起来加入与限制代码)•易于构建正确加入代码(尤其是在"外"的情况下连接)•便携式语法上的所有其他符合ANSI的数据库,如MS SQL Server将工作,DB2,MySQL和PostgreSQL等•由于它是普遍接受的标准,这是所有未来的数据库和第三方厂商的工具•专有的Oracle外连接(+)语法只能在一个方向上使用的一般目标一段时间,它不能执行完全外连接•加上Oracle文档中的这些附加限制:o(+)运算符只能应用于列,而不能应用于任意表达式.但是,任意表达式可以包含一个或多个用(+)运算符标记的列.o包含(+)运算符的条件不能与OR逻辑运算符组合使用.o条件不能使用IN比较条件将标有(+)运算符的列与表达式进行比较.o条件无法将使用(+)运算符标记的任何列与子查询进行比较."
因此,是时候采用ANSI连接语法 - 并进入21世纪
如果有,我还没有看到它.特别是对于外连接更喜欢ANSI语法的原因(除非非标准(+)符号,特定于Oracle的符号)是使用ANSI语法可以表达更多外连接.限制"ORA-01417:表可以外连接到最多一个其他表"适用于(+)外连接但不适用于ANSI外连接.此处记录的其他限制(+)不适用于ANSI外连接.
一位备受尊敬的Oracle专家实际上建议坚持内部联接的旧语法 - 请参阅Jonathan Lewis的博客.他说,无论如何,ANSI连接都转变为传统的Oracle连接.我不同意他100%(我更喜欢ANSI加入我自己),但不会声称他对该主题的知识的一小部分.
简而言之,ANSI外连接在技术上优于旧(+)连接,而对于内连接,它更像是一种风格问题.
| 归档时间: |
|
| 查看次数: |
5034 次 |
| 最近记录: |