環境
Red Hat Enterprise Linux Server release 5.8 (Tikanga)
ORACLE Release 11.2.0.3.0 Productionsql
我用expdp,impdp複製一個shema,在impdp導入的時候報錯
ORA-39083: Object type TYPE failed to create with error:
ORA-02304: invalid object identifier literal
Failing sql is:
CREATE TYPE "GENIDCDEV2"."ARRAY_TYPE2" OID '0367306C82464BF1E0534E092D0A4AB5' is array(48) of varchar2(255)ide
查看官方文檔的impdp章節,搜索OID,發現了以下有用的內容
查看impdp help=y 能夠使用一個參數:transformorm
TRANSFORM
Enables you to alter object creation DDL for objects being imported.對象
OID - If the value is specified as n, the assignment of the exported OID during the
creation of object tables and types is inhibited. Instead, a new OID is assigned.
This can be useful for cloning schemas, but does not affect referenced objects. The
default value is y.ci
這個參數默認是Y,若是改爲N,那麼導入的時候會把各個對象從新賦予新的OID。
transform=oid:n
這樣,再用impdp導入的時候就不會出現
ORA-39083,ORA-02304
注意:exp/imp不支持oid轉換,又是一個使用數據泵的優點。文檔
所以我想到了兩種方法能夠解決問題
1.用下面impdp語句從新導入
impdp system/'*****' directory=dir_lisx REMAP_SCHEMA=WMSUAT:GENIDCDEV2 dumpfile=wmsuat20150304.dump include=TYPE transform=oid:n logfile=impdp_wmsuat20150304_2.logget
Import: Release 11.2.0.3.0 - Production on Wed Mar 4 14:55:40 2015it
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.io
Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Master table "SYSTEM"."SYS_IMPORT_FULL_01" successfully loaded/unloaded
Starting "SYSTEM"."SYS_IMPORT_FULL_01": system/******** directory=dir_lisx REMAP_SCHEMA=WMSUAT:GENIDCDEV2 dumpfile=wmsuat20150304.dump include=TYPE transform=oid:n logfile=impdp_wmsuat20150304_2.log
Processing object type SCHEMA_EXPORT/TYPE/TYPE_SPEC
Job "SYSTEM"."SYS_IMPORT_FULL_01" successfully completed at 14:55:45編譯
2.手工重建剛纔導入失敗的type
覈查type的ddl語句
SELECT dbms_metadata.get_ddl('TYPE','ARRAY_TYPE2','WMSUAT') from dual ;
CREATE OR REPLACE TYPE "WMSUAT"."ARRAY_TYPE2" is array(48) of varchar2(255) ;
記得從新編譯一下新clone的schemaEXEC DBMS_UTILITY.compile_schema(schema => 'GENIDCDEV2');