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