expdp/impdp來解決exp/imp出現的錯誤並匯入指定表空間

kuqlan發表於2011-08-05

ERP系統版本更新原因需要在測試系統上透過IMP/EXP方式進行了備份恢復資料,在imp方式匯出是報如下錯誤:

EXP-00091: Exporting questionable statistics.

EXP-00091: Exporting questionable statistics.

EXP-00091: Exporting questionable statistics.

匯入時發現如下錯誤提示:

Column 17

Column 18

Column 19

Column 20 CanEmpty{}|CheckLenX{FEditLen}|CheckLenMax{30}

Column 21 2

Column 22 com.kingdee.eas.base.form.ide.model.property.DefVa...

Column 23

IMP-00019: row rejected due to ORACLE error 1

IMP-00003: ORACLE error 1 encountered

ORA-00001: unique constraint (GDERPTEST.PK_T_BAS_ELEPROP) violated

Column 1 C8t8LfYGBE2XpayN4Ztr160AB873

Column 2 22

Column 3 Default Val

Column 4 ???

Column 5 ???

Column 6 Default Val

另外一個異常就是,在匯入時出現將資料匯入到原來用的表空間中(不是新建使用者預設的表空間),因此按expdp/impdp方式進行備份恢復的測試。具體過程如下:

[@more@]

1.建立轉儲檔案(存放匯出資料的檔案)存放的目錄

[oracle@gderp1 data]$ sqlplus / as sysdba

SQL> create directory dump_dir as '/data/dump_dir'

SQL> grant read,write on directory dump_dir to erp;

--執行匯出:

expdp erp/erp dumpfile=dump_dir:erp0711.dmp logfile=dump_dir:erp0711.log

匯出完畢後在執行如下命令進行了備份的匯入:

impdp erpnew/erpnew schemas="erp" remap_schema="erp:erpnew" dumpfile=dump_dir:erp0711.dmp logfile=dump_dir:erpnew_imp.log

匯入成功了,但是發現將資料匯入到原來表空間而不是新建使用者預設表空間。

因此採用如下方法,檢視了匯出DMP檔案中的有關DDL語句:

impdp system/system schemas="erp" dumpfile=dump_dir:erp0711.dmp nologfile=y sqlfile=dump_dir:erp_full.sql

部分結果如下:

...

Processing object type SCHEMA_EXPORT/FUNCTION/FUNCTION

Processing object type SCHEMA_EXPORT/PROCEDURE/PROCEDURE

Processing object type SCHEMA_EXPORT/FUNCTION/ALTER_FUNCTION

Processing object type SCHEMA_EXPORT/PROCEDURE/ALTER_PROCEDURE

Processing object type SCHEMA_EXPORT/VIEW/VIEW

Processing object type SCHEMA_EXPORT/TABLE/INDEX/FUNCTIONAL_AND_BITMAP/INDEX

Processing object type SCHEMA_EXPORT/TABLE/INDEX/STATISTICS/FUNCTIONAL_AND_BITMAP/INDEX_STATISTICS

Processing object type SCHEMA_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS

Job "SYSTEM"."SYS_SQL_FILE_SCHEMA_01" successfully completed at 13:08:48

執行完畢後,檢視gderp_full.sql檔案內容,部分內容如下所示:

[oracle@erp1 dump_dir]$ more erp_full.sql

-- CONNECT SYSTEM

-- new object type path is: SCHEMA_EXPORT/PRE_SCHEMA/PROCACT_SCHEMA

-- CONNECT ERP

BEGIN

sys.dbms_logrep_imp.instantiate_schema(schema_name=>SYS_CONTEXT('USERENV','CURRENT_SCHEMA'), export_db_name=>'EAS', inst_scn=>'108184772');

COMMIT;

END;

/

-- new object type path is: SCHEMA_EXPORT/TABLE/TABLE

-- CONNECT SYSTEM

CREATE TABLE "ERP"."DW_BD_PUMPRECORD"

( "FTABLE" VARCHAR2(80),

"FSYSTEM" NUMBER(10,0),

"FCURRENTPERIODID" VARCHAR2(44),

"FBEGINDATE" TIMESTAMP (6),

"FENDDATE" TIMESTAMP (6),

"FISCLOSEDACCOUNT" NUMBER(10,0),

"FPUMPTIME" TIMESTAMP (6)

) PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING

STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645

PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)

TABLESPACE "EASDATA" ;

原來是將建立表和索引等物件的TABLESPACE "EASDATA" 屬性已經寫死的,知道原因,則解決起來就簡單了。



解決辦法
1

impdp erpnew/erpnew schemas="erp" remap_schema="erp:erpnew" remap_tablespace=easdata:erpnew dumpfile=dump_dir:erp0711.dmp logfile=dump_dir:erpnew_imp.log

另外一種在不知道remap_tablespace引數之前想出來的解決辦法如下:

首先用ultraedit開啟gderp_full.sql並將TABLESPACE "EASDATA" 屬性批次替換為想要的表空間,然後在SQL Plus裡呼叫該sql檔案並建立這些物件的定義,最後根據content=DATA_ONLY選項只匯入資料;

impdp erpnew/erpnew schemas="erp" remap_schema="erp:erpnew" content=DATA_ONLY dumpfile=dump_dir:erp0711.dmp logfile=dump_dir:erpnew_imp.log

注:

content=content_option Specifies whether data, metadata, or both are imported.

Valid values are: DATA_ONLY (data only), METADATA_ONLY

(metadata only), and the default ALL (both).

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

相關文章