Oracle 11g下ORA-01417的解決方案

來源:互聯網
上載者:User

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

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.