你好,游客 登录 注册 搜索
背景:
阅读新闻

Oracle 11g下ORA-01417的解决方法

[日期:2014-11-29] 来源:Linux社区  作者:stevendbaguo [字体:大 中 小]

今天有客户反馈,有一条SQL在12C上没有问题,在Oracle 11g上就报错,报错内容是ORA-01417: 表可以外部连接到至多一个其他的表。分析了下SQL,抽象为下列的例子。

在12c下没有问题:

SQL> select * from v$version;

BANNER                                                                              CON_ID
-------------------------------------------------------------------------------- ----------
Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production              0
PL/SQL Release 12.1.0.1.0 - Production                                                    0
CORE    12.1.0.1.0      Production                                                        0
TNS for Linux: Version 12.1.0.1.0 - Production                                            0
NLSRTL Version 12.1.0.1.0 - Production                                                    0
drop table test1 purge;
drop table test2 purge;
drop table test3 purge;
create table test1 (id number primary key);
create table test2 (id number);
create table test3 (dept_id number,measure_id number);
insert into test1 values(1);
insert into test1 values(2);
insert into test1 values(3);
insert into test2 values(10);
insert into test2 values(20);
insert into test3 values(1,10);
commit;

SQL> select *
      from test1, test2, test3
    where test1.id = test3.dept_id(+)
      and test2.id = test3.measure_id(+);
        ID        ID    DEPT_ID MEASURE_ID
---------- ---------- ---------- ----------
        1        10          1        10
        2        10
        2        20
        3        20
        1        20
        3        10
已选择6行。

在11g下有问题:

SQL> select * from v$version;
BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
PL/SQL Release 11.2.0.1.0 - Production
CORE    11.2.0.1.0      Production
TNS for Linux: Version 11.2.0.1.0 - Production
NLSRTL Version 11.2.0.1.0 - Production
SQL> select *
      from test1, test2, test3
    where test1.id = test3.dept_id(+)
      and test2.id = test3.measure_id(+);
 where test1.id = test3.dept_id(+)
                *
第 3 行出现错误:
ORA-01417: 表可以外部连接到至多一个其他的表

--把test1和test2联合起来,再与test3关联,问题解决

SQL> select *
      from (select test1.id dept_id, test2.id measure_id from test1, test2) a,
          test3
    where a.dept_id = test3.dept_id(+)
      and a.measure_id = test3.measure_id(+);

在CentOS 6.4下安装Oracle 11gR2(x64) http://www.linuxidc.com/Linux/2014-02/97374.htm

Oracle 11gR2 在VMWare虚拟机中安装步骤 http://www.linuxidc.com/Linux/2013-09/89579p2.htm

Debian 下 安装 Oracle 11g XE R2 http://www.linuxidc.com/Linux/2014-03/98881.htm

Oracle Linux 6.5安装Oracle 11.2.0.4 x64 http://www.linuxidc.com/Linux/2014-11/109903.htm

更多Oracle相关信息见Oracle 专题页面 http://www.linuxidc.com/topicnews.aspx?tid=12

本文永久更新链接地址:http://www.linuxidc.com/Linux/2014-11/110007.htm

linux
相关资讯       ORA-01417 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款