研发给了一个需求,需要将生产库的某个表导入测试中,源端用户与目标端用户名不一致,目标端换张新表,不用旧表,挺简单的一个操作,但是还是出了点小问题,写下来给自己当个笔记。

源端:12.2.0.1.0环境

目标:11.2.0.3.0环境

源端执行数据泵导出该表:

expdp \'sys/xxxxx@FINPDB AS SYSDBA\' dumpfile=PROD.T_PRD_OPEN180606.dmp directory=exp_shengchan logfile=PROD.T_PRD_OPEN1806.log tables=PROD.T_PRD_OPEN version=11.2.0.3.0

高版本的数据库导入到低版本的数据库中,切记加version条件,要么会报错;

然后将抽到的DMP文件scp至测试;

scp  PROD.T_PRD_OPEN180606.dmp* xx.16.xx.xx:/home/oracle/exp_shengchan

目标执行数据泵导出该表:

impdp  \'sys/xxxx@OTESTDB AS SYSDBA\' directory=exp_shengchan dumpfile=PROD.T_PRD_OPEN180606.dmp  logfile=CASH_PROD.T_PRD_OPEN180606.log remap_table=PROD.T_PRD_OPEN:CASH_UAT.T__PRD_OPEN_FIN remap_schema=CASH_PROD:CASH_UAT  remap_tablespace=PROD_DATA:CASH_UAT_DATA exclude=index table_exists_action=truncate

导入过程提示:

Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
. . imported "CASH_UAT"."CASH_UAT.T_URM_PRD_OPEN_FIN"             236.2 MB  398728 rows

靠!!!!!!!!!!!

impdp问题笔录_Oracle


remap_table时候需要注意:


remap_table、remap_tablespace多组对象转换的话,每组对象之间用逗号隔开

tables多张表时,每张表之间用逗号隔开

Remap_tablespace如果需要转换多个表空间,如A1转换成B1,A2转换成B1,有如下两种方式

remap_tablespace=A1:B1 remap_tablespace=A2:B1

remap_tablespace= A1:B1, A2:B1

Remap_table如果需要转换多个表名

同一个schema的情况下,如A1转换成B1,A2转换成B1,有如下两种方式

remap_table=A1:B1 remap_table=A2:B1

remap_table= A1:B1, A2:B1

impdp关于tables和remap_tables的一些注意事项

1. expdp时写上tables=(表)表示导出某些表;impdp时不写tables条件表示导入dumpfile中的所有表,impdp时写tables=(表)条件表示只导入指定的表,当然如果tables=(dumpfile中的所有表)也就是导入dumpfile中的所有表;且如果用system执行impdp时则tables=(表)时必须加上schema.表名,否则会默认是为system下面的表,会导致报错

2. remap_table如果在同一个schema下进行,虽然不要加remap_schema,但是remap_table冒号前面的表名一定要带schema信息,冒号后面的表名一定不能带schema信息

3. remap_table如果在不同schema的情况下进行,如user1.A1转换成user2.B1,user1.A2转换成user2.B1,必须加remap_schema,且remap_table冒号前面的表名一定要带schema信息,冒号后面的表名一定不能带schema信息

有如下两种方式

remap_table= user1.A1:B1 remap_table= user1.A2:B1 remap_schema= user1: user2

remap_table= user1. A1:B1, user1.A2:B1 remap_schema= user1: user2

跨schema只导出导入表并重命名的标准方式如下

expdp时tables写上schema.表名并用逗号隔开

impdp时需要remap_schema, tables可写可不写,remap_table冒号前面的表名加上schema,冒号后面的表名不加schema


再来一次!这次不能加用户名!!

impdp  \'sys/xxxx@OTESTDB AS SYSDBA\' directory=exp_shengchan dumpfile=PROD.T_PRD_OPEN180606.dmp  logfile=CASH_PROD.T_PRD_OPEN180606.log remap_table=PROD.T_PRD_OPEN:T__PRD_OPEN_FIN remap_schema=CASH_PROD:CASH_UAT  remap_tablespace=PROD_DATA:CASH_UAT_DATA exclude=index table_exists_action=truncate


导入过程中提示报错:

Processing object type TABLE_EXPORT/TABLE/PROCACT_INSTANCE 

ORA-39126: Worker unexpected fatal error in KUPW$WORKER.LOAD_MD_TRANSFORMS []  

ORA-31604: invalid transform NAME parameter "MODIFY" for object type PROCACT_INSTANCE in function ADD_TRANSFORM 


ORA-06512: at "SYS.DBMS_SYS_ERROR", line 86 

ORA-06512: at "SYS.KUPW$WORKER", line 9710 

解决方法,碰到bug了,参考MOS :1596495.1

SOLUTION

At the time of writing there was no patch available. You can workaround the issue by specifying exclude=PROCACT_INSTANCE.
To implement the fix, please execute the following step:

  • Use an additional parameter that is exclude=PROCACT_INSTANCE during impdp
    - OR -
  • Redo the export with exclude=PROCACT_INSTANCE and perform import using new dumpfiles.

The use of the exclude=PROCACT_SYSTEM will exclude the resource manager objects such as resource plans and groups.
That means that if you had resource plans and groups, you will need to recreate them after the import.

再来!

impdp  \'sys/xxx@OTESTDB AS SYSDBA\' directory=exp_shengchan dumpfile=PROD.T_PRD_OPEN180606.dmp  logfile=PROD.T_PRD_OPEN180606.log remap_table=PROD.T_URM_PRD_OPEN:T_URM_PRD_OPEN_FIN remap_schema=CASH_PROD:CASH_UAT exclude=PROCACT_INSTANCE remap_tablespace=CASH_PROD_DATA:CASH_UAT_DATA exclude=index table_exists_action=truncate

导入完成!