当前位置:Gxlcms > mysql > Oracle11g下ORA-01417的解决方法

Oracle11g下ORA-01417的解决方法

时间:2021-07-01 10:21:17 帮助过:497人阅读

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

今天有客户反馈,有一条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)

Oracle 11gR2 在VMWare虚拟机中安装步骤

Debian 下 安装 Oracle 11g XE R2

Oracle Linux 6.5安装Oracle 11.2.0.4 x64

本文永久更新链接地址:

linux

人气教程排行