exp/imp 报错处理(EXP-00003 / IMP-00019 / IMP-00058)
MOS 文章参考
OERR: EXP 3 "no storage definition found for segment(%lu, %lu)" (文档 ID 21599.1)
EXP-00003 When Exporting From 9.2.0.5.0 Or Any Higher Release With A Pre-9.2.0.5.0 Export Client (文档 ID 274076.1)
一、EXP 导出报错(数据库版本 11.2.0.4.0)
. . exporting table FANZC_ALL_DEV_CDMA_USER_M 184220 rows exported
EXP-00003: no storage definition found for segment(20, 12647)
. . exporting table SJZX_WH_FUKA_BX_010_D
. . exporting partition PART_201701 0 rows exported
. . exporting partition PART_201702 279875 rows exported
. . exporting partition PART_201703 0 rows exported
. . exporting partition PART_201704 0 rows exported
. . exporting partition PART_201705 0 rows exported
查看源库中表的行数,可以发现,所有行都已经被导出
根据 MOS 文章 21599.1,报错中的 (%lu, %lu) 表示 (文件号 F,块号 B)
查询 dba_segments 确定 段 的名字,但是在数据库中并没有查到
select * from dba_segments where HEADER_FILE = F and HEADER_BLOCK = B;
根据 MOS 文章 274076.1 的解决方式:
1)$ORACLE_HOME/rdbms/admin/catexp.sql 文件中,定义了 EXU9TNE 视图的定义
REM
REM find out correct size of second extent using uet$
REM
CREATE OR REPLACE VIEW exu9tne (
tsno, fileno, blockno, length) AS
SELECT ts#, segfile#, segblock#, length
FROM sys.uet$
WHERE ext# = 1
/
GRANT SELECT ON sys.exu9tne TO PUBLIC;
REM
REM find out correct size of second extent using x$ktfbue (for bitmapped TS)
REM
CREATE OR REPLACE VIEW exu9tneb (
tsno, fileno, blockno, length) AS
SELECT ktfbuesegtsn, ktfbuesegfno, ktfbuesegbno, ktfbueblks
FROM sys.x$ktfbue
WHERE ktfbueextno = 1
/
GRANT SELECT ON sys.exu9tneb TO PUBLIC;
查询 dba_views 进行验证
SQL> select OWNER,VIEW_NAME,TEXT_LENGTH,TEXT from dba_views where view_name ='EXU9TNE';
OWNER VIEW_NAME TEXT_LENGTH TEXT
------------------------------ ------------------------------ ----------- -----------------------------------------------------
SYS EXU9TNE 90 SELECT ts#, segfile#, segblock#, length
FROM sys.uet$
WHERE ext# = 1
2)使用 SYS 重建一下这个视图
CREATE OR REPLACE VIEW exu9tne (
tsno, fileno, blockno, length) AS
SELECT ts#, segfile#, segblock#, length
FROM sys.uet$
WHERE ext# = 1
UNION ALL
SELECT * from sys.exu9tneb
/
3)重新执行导出
4)导出完成后,将视图 EXU9TNE 还原
二、IMP 导入报错
错误描述:在源库(10.2.0.4.0)使用 exp 导出后,在新库(11.2.0.4.0)使用 imp 进行导入,出现一些错误
源库导出
exp 'rpt_hbtele/rpt_ods*147' FILE=/oratmp2/E_CHANNEL_DTBLCG_D.dmp TABLES=RPT_HBTELE.E_CHANNEL_DTBLCG_D direct=y recordlength=65535 log=/oratmp2/E_CHANNEL_DTBLCG_D_exp_table.log buffer=5400000 statistics=none
目标库导入
imp 'rpt_hbtele/JfRpt_hbtele_#95!Cnob' FILE=/oratmp2/E_CHANNEL_DTBLCG_D.dmp TABLES=E_CHANNEL_DTBLCG_D ignore=y commit=y log=/oratmp2/E_CHANNEL_DTBLCG_D_imp_table.log buffer=5400000 statistics=none
错误一:ORA-12899
IMP-00019: row rejected due to ORACLE error 12899
IMP-00003: ORACLE error 12899 encountered
ORA-12899: value too large for column "RPT_HBTELE"."E_CHANNEL_DTBLCG_D"."SERVID" (actual: 21, maximum: 20)
Column : 171204ismp_prod0213143
Column : 13315911100
.......
Column : 20171204085313
Column :
Column :
Column :
Column :
Column :
Column :
Column : 135000000000000000851 该列的长度是 21 但是创建表时指定的数据类型是 varchar2(20)
Column :
Column : 1
.........
错误原因:源库更改了 SERVID 的列宽,由 varchar2(20) 更改为 varchar2(40),但是目标库的元数据没有更新
解决方式:在目标库修改列宽,与源库保持一致;然后将失败的表数据重新导入
alter table E_CHANNEL_DTBLCG_D modify SERVID varchar2(40);
错误二:ORA-00904
. . importing table "SJZX_WH_BXL_DINNER_030_D"
IMP-00058: ORACLE error 904 encountered
ORA-00904: "ONNETNEW_SN_199_2": invalid identifier
错误原因:源库中,SJZX_WH_BXL_DINNER_030_D 表增加了几个字段(随着业务需要,某些表会增加字段)
SQL> desc RPT_HBTELE.SJZX_WH_BXL_DINNER_030_D;
Name Null? Type
----------------------------------------- -------- ----------------------------
....
....
NEW_109_2_DR_SN NUMBER
NEW_109_2_DY_SN NUMBER
TRANS_109_2_DR_SN NUMBER
TRANS_109_2_DY_SN NUMBER
ONNET_SN_109_2 NUMBER
ONNETNEW_SN_109_2 NUMBER
NEW_199_2_DR_SN NUMBER
NEW_199_2_DY_SN NUMBER
TRANS_199_2_DR_SN NUMBER
TRANS_199_2_DY_SN NUMBER
ONNET_SN_199_2 NUMBER
ONNETNEW_SN_199_2 NUMBER
解决方式:在目标库添加相应字段;然后将失败的表数据重新导入
alter table SJZX_WH_BXL_DINNER_030_D add
(
NEW_109_2_DR_SN NUMBER ,
NEW_109_2_DY_SN NUMBER ,
TRANS_109_2_DR_SN NUMBER ,
TRANS_109_2_DY_SN NUMBER ,
ONNET_SN_109_2 NUMBER ,
ONNETNEW_SN_109_2 NUMBER ,
NEW_199_2_DR_SN NUMBER ,
NEW_199_2_DY_SN NUMBER ,
TRANS_199_2_DR_SN NUMBER ,
TRANS_199_2_DY_SN NUMBER ,
ONNET_SN_199_2 NUMBER ,
ONNETNEW_SN_199_2 NUMBER
);
错误三:IMP-00013
场景描述:在源库(10.2.0.4.0)使用 ALLDM 导出,在新库(11.2.0.4.0)使用 ALLDM 用户导入,出现的报错
Export file created by EXPORT:V10.02.01 via direct path
IMP-00013: only a DBA can import a file exported by another DBA
IMP-00000: Import terminated unsuccessfully
1)查看源库中 ALLDM 用户的角色
SQL> select * from dba_role_privs where grantee='ALLDM';
GRANTEE GRANTED_ROLE ADM DEF
------------------------------ ------------------------------ --- ---
ALLDM EXP_FULL_DATABASE NO YES
ALLDM ROLE_DSS NO YES
2)查看目标库中 ALLDM 用户的角色
SQL> select * from dba_role_privs where grantee='ALLDM';
GRANTEE GRANTED_ROLE ADM DEF
------------------------------ ------------------------------ --- ---
ALLDM RESOURCE NO YES
ALLDM EXP_FULL_DATABASE NO YES
ALLDM ROLE_DSS NO YES
错误原因:如果导出文件是由一个具有 EXP_FULL_DATABASE 角色的用户创建的,那么你必须具有 IMP_FULL_DATABASE 角色才可以导入它
解决方式:
1)将 IMP_FULL_DATABASE 角色授予 ALLDM 用户 grant IMP_FULL_DATABASE to ALLDM;
2)或使用 SYS 用户导入
imp \'sys/oracle123 AS SYSDBA\'
查看 SYS 用户和 导入导出相关的角色
SQL> select * from dba_role_privs where granted_role like '%FULL%' and grantee='SYS';
GRANTEE GRANTED_ROLE ADM DEF
------------------------------ ------------------------------ --- ---
SYS IMP_FULL_DATABASE YES YES
SYS EXP_FULL_DATABASE YES YES
SYS DATAPUMP_IMP_FULL_DATABASE YES YES
SYS DATAPUMP_EXP_FULL_DATABASE YES YES