• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

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

mysql 搞代码 4年前 (2022-01-09) 18次浏览 已收录 0个评论

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

本文来源gao!%daima.com搞$代*!码$网3

st2 (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

本文永久更新链接地址:


搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:Oracle 11g下ORA-01417的解决方法

喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址