导入一个有lob类型字段的表且存在与导入表同名的同义词会报ora-01403错误

如果你一表包含一个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错误的.

发表评论

电子邮件地址不会被公开。