匯入一個有lob型別欄位的表且存在與匯入表同名的同義詞會報ora-01403錯誤

eric0435發表於2013-12-20

如果你一表包含一個lob型別的列如果存在一個與這個表同名的同義詞那麼在匯入這個表的資料時會報ora-01403錯:
在oracle10g中的測試情況如下:
1.建立兩個使用者test和cs

idle> conn sys/zzh_2046@jy_1 as sysdba
已連線。
sys@JINGYONG> grant dba to test identified by test;

授權成功。

sys@JINGYONG> grant dba to cs identified by cs;

授權成功。

2.在使用者test中建立一個有clob型別的列的表emp並向表中插入幾行記錄

sys@JINGYONG> conn test/test@jy_1
已連線。
test@JINGYONG> create table emp (col_a number, col_b varchar2(3), c_lob clob);

表已建立。

test@JINGYONG>
test@JINGYONG> INSERT INTO EMP VALUES (180, 'a', '01010101010101');

已建立 1 行。

test@JINGYONG> INSERT INTO EMP VALUES (181, 'a', '01010101010101');

已建立 1 行。

test@JINGYONG> INSERT INTO EMP VALUES (182, 'a', '01010101010101');

已建立 1 行。

test@JINGYONG> INSERT INTO EMP VALUES (183, 'a', '01010101010101');

已建立 1 行。

test@JINGYONG> INSERT INTO EMP VALUES (184, 'a', '01010101010101');

已建立 1 行。

test@JINGYONG> INSERT INTO EMP VALUES (185, 'a', '01010101010101');

已建立 1 行。

test@JINGYONG> commit;

提交完成。

連線到使用者cs並建立一個同義詞叫EMP
1.建立同義詞EMP是使用test.emp表來建立(也可以用任意表來建立同義詞EMP,只要保證同義詞的名字與要匯入表的名字相同就行)

test@JINGYONG> conn cs/cs@jy_1
已連線。
cs@JINGYONG> create synonym EMP for test.EMP;

同義詞已建立。

cs@JINGYONG> commit;

提交完成。

cs@JINGYONG>



C:\Documents and Settings\Administrator>exp test/test@jy_1 file=f:\emp.dmp table
s=EMP

Export: Release 10.2.0.1.0 - Production on 星期四 12月 19 22:00:15 2013

Copyright (c) 1982, 2005, Oracle.  All rights reserved.


連線到: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
已匯出 ZHS16GBK 字符集和 AL16UTF16 NCHAR 字符集

即將匯出指定的表透過常規路徑...
. . 正在匯出表                             EMP匯出了           6 行
成功終止匯出, 沒有出現警告。

C:\Documents and Settings\Administrator>imp cs/cs@jy_1 file=f:\emp.dmp tables=EM
P ignore=y

Import: Release 10.2.0.1.0 - Production on 星期四 12月 19 22:01:48 2013

Copyright (c) 1982, 2005, Oracle.  All rights reserved.


連線到: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options

經由常規路徑由 EXPORT:V10.02.01 建立的匯出檔案

警告: 這些物件由 TEST 匯出, 而不是當前使用者

已經完成 ZHS16GBK 字符集和 AL16UTF16 NCHAR 字符集中的匯入
. 正在將 TEST 的物件匯入到 CS
. 正在將 TEST 的物件匯入到 CS
. . 正在匯入表                           "EMP"
IMP-00058: 遇到 ORACLE 錯誤 1403
ORA-01403: no data found匯入了           6 行
成功終止匯入, 但出現警告。

2.使用表t1來建立同義詞EMP

cs@JINGYONG> create synonym EMP for sys.t1;

同義詞已建立。

cs@JINGYONG> drop table emp;
drop table emp
           *
第 1 行出現錯誤:
ORA-00942: 表或檢視不存在

C:\Documents and Settings\Administrator>imp cs/cs@jy_201 file=f:\emp.dmp tables=
EMP ignore=y

Import: Release 10.2.0.1.0 - Production on 星期五 12月 20 08:13:07 2013

Copyright (c) 1982, 2005, Oracle.  All rights reserved.


連線到: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

經由常規路徑由 EXPORT:V10.02.01 建立的匯出檔案

警告: 這些物件由 TEST 匯出, 而不是當前使用者

已經完成 ZHS16GBK 字符集和 AL16UTF16 NCHAR 字符集中的匯入
. 正在將 TEST 的物件匯入到 CS
. 正在將 TEST 的物件匯入到 CS
. . 正在匯入表                           "EMP"
IMP-00058: 遇到 ORACLE 錯誤 1403
ORA-01403: 未找到任何資料
IMP-00058: 遇到 ORACLE 錯誤 904
ORA-00904: "C_LOB": 識別符號無效
成功終止匯入, 但出現警告。

11g的測試
1.建立兩個使用者test和cs

idle> conn sys/zzh_2046@jy_201 as sysdba
已連線。
sys@JINGYONG> grant dba to test identified by test;

授權成功。

sys@JINGYONG> grant dba to cs identified by cs;

2.在使用者test中建立一個有clob型別的列的表emp並向表中插入幾行記錄

sys@JINGYONG> conn test/test@jy_201
已連線。
test@JINGYONG> create table emp (col_a number, col_b varchar2(3), c_lob clob);

表已建立。

test@JINGYONG>
test@JINGYONG> INSERT INTO EMP VALUES (180, 'a', '01010101010101');

已建立 1 行。

test@JINGYONG> INSERT INTO EMP VALUES (181, 'a', '01010101010101');

已建立 1 行。

test@JINGYONG> INSERT INTO EMP VALUES (182, 'a', '01010101010101');

已建立 1 行。

test@JINGYONG> INSERT INTO EMP VALUES (183, 'a', '01010101010101');

已建立 1 行。

test@JINGYONG> INSERT INTO EMP VALUES (184, 'a', '01010101010101');

已建立 1 行。

test@JINGYONG> INSERT INTO EMP VALUES (185, 'a', '01010101010101');

已建立 1 行。

test@JINGYONG> commit;

提交完成。

連線到使用者cs並建立一個同義詞叫EMP
1.建立同義詞EMP是使用test.emp表來建立(也可以用任意表來建立同義詞EMP,只要保證同義詞的名字與要匯入表的名字相同就行)

test@JINGYONG> conn cs/cs@jy_201
已連線。
cs@JINGYONG> create synonym EMP for test.EMP;

同義詞已建立。

cs@JINGYONG> commit;

提交完成。

cs@JINGYONG>

使用10g的客戶端連線到11g的資料庫進行匯出操作

C:\Documents and Settings\Administrator>exp test/test@jy_201 file=f:\emp.dmp tab
les=EMP

Export: Release 10.2.0.1.0 - Production on 星期四 12月 19 22:10:28 2013

Copyright (c) 1982, 2005, Oracle.  All rights reserved.


連線到: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
已匯出 ZHS16GBK 字符集和 AL16UTF16 NCHAR 字符集

即將匯出指定的表透過常規路徑...
. . 正在匯出表                             EMP匯出了           6 行
成功終止匯出, 沒有出現警告。

使用10g的客戶端連線到11g的資料庫進行匯入操作也會報ora-01403錯誤

C:\Documents and Settings\Administrator>imp cs/cs@jy_201 file=f:\emp.dmp tables=
EMP ignore=y

Import: Release 10.2.0.1.0 - Production on 星期四 12月 19 22:11:27 2013

Copyright (c) 1982, 2005, Oracle.  All rights reserved.


連線到: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

經由常規路徑由 EXPORT:V10.02.01 建立的匯出檔案

警告: 這些物件由 TEST 匯出, 而不是當前使用者

已經完成 ZHS16GBK 字符集和 AL16UTF16 NCHAR 字符集中的匯入
. 正在將 TEST 的物件匯入到 CS
. 正在將 TEST 的物件匯入到 CS
. . 正在匯入表                           "EMP"
IMP-00058: 遇到 ORACLE 錯誤 1403
ORA-01403: 未找到任何資料匯入了           6 行
成功終止匯入, 但出現警告。

使用11g的客戶端連線到11g的資料庫進行匯出操作

[oracle@jingyong ~]$ exp test/test file=/home/oracle/emp.dmp tables=EMP

Export: Release 11.2.0.1.0 - Production on Sat Dec 7 01:41:44 2013

Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.


Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Export done in ZHS16GBK character set and AL16UTF16 NCHAR character set

About to export specified tables via Conventional Path ...
. . exporting table                            EMP         12 rows exported
Export terminated successfully without warnings.

使用11g的客戶端連線到11g的資料庫進行匯出操作在有與匯入表同名的同義詞的情況下不會報ora-01403錯誤.

[oracle@jingyong ~]$ imp cs/cs file=/home/oracle/emp.dmp tables=EMP ignore=y

Import: Release 11.2.0.1.0 - Production on Sat Dec 7 01:42:20 2013

Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.


Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

Export file created by EXPORT:V11.02.00 via conventional path

Warning: the objects were exported by TEST, not by you

import done in ZHS16GBK character set and AL16UTF16 NCHAR character set
. importing TEST's objects into CS
. importing TEST's objects into CS
. . importing table                          "EMP"         12 rows imported
Import terminated successfully without warnings.
[oracle@jingyong ~]$

下面刪除與表同名的同義詞而且使用10g的客戶端連線11g資料庫進行匯入操作也是不會報ora-01403錯誤的

C:\Documents and Settings\Administrator>sqlplus /nolog

SQL*Plus: Release 10.2.0.1.0 - Production on 星期五 12月 20 07:51:34 2013

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

idle> conn cs/cs@jy_1
已連線。
cs@JINGYONG> drop synonym EMP;

同義詞已刪除。

C:\Documents and Settings\Administrator>imp cs/cs@jy_201 file=f:\emp.dmp tables=
EMP ignore=y

Import: Release 10.2.0.1.0 - Production on 星期五 12月 20 09:02:40 2013

Copyright (c) 1982, 2005, Oracle.  All rights reserved.


連線到: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

經由常規路徑由 EXPORT:V10.02.01 建立的匯出檔案

警告: 這些物件由 TEST 匯出, 而不是當前使用者

已經完成 ZHS16GBK 字符集和 AL16UTF16 NCHAR 字符集中的匯入
. 正在將 TEST 的物件匯入到 CS
. 正在將 TEST 的物件匯入到 CS
. . 正在匯入表                           "EMP"匯入了           6 行
成功終止匯入, 沒有出現警告。

出現這個問題的原因:
是因為bug 7422758 IMPORTING A TABLE WITH A BLOB OR CLOB USING A SYNONYM CAUSES ORA-1403, fixed with 11.2.

解決方法:
1. 升級到11.2.
2. 打7422758補釘

注意:
在oracle11gr2版本中如果在對某個使用者匯入某個表時,而這個表有一個lob型別的列且這個使用者存一個與要匯入表同名的同義詞,在這種情況下使用oracle11gr2版本的客戶端進行匯出再匯入是不會報ora-01403錯誤.如果使用oracle11gr2版本以下的客戶端進行匯出和匯入也是會報ora-01403錯誤的.

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/26015009/viewspace-1063849/,如需轉載,請註明出處,否則將追究法律責任。

相關文章