EXPDP出来的DMP文件包含2个Schema的表,现在要IMPDP到一个Schema里面
试了几把都报错,好久不用逻辑导出入,折腾了好久,出现各种错误
1、创建目录并授权
create or replace directory DUMPDIR as '/home/oracle/dump_dir';
grant read,write on directory DUMPDIR to test2;
2、BOOK用户的表T_BOOK_DEPOSIT_530 impdp导入TEST2用户下
impdp test2/test123 remap_schema=BOOK:TEST2 tables=BOOK.T_BOOK_DEPOSIT_530 directory=DUMPDIR dumpfile=OA188672.dmp logfile=OA188672.log
----------------------------------------------------------------------------------------
err log:
Starting "TEST"."SYS_IMPORT_FULL_01": test/******** parallel=4 remap_schema=TESTUSER:TEST dumpfile=OA186751.dmp logfile=OA186751_imp.log DIRECTORY=DUMPDIR
Processing object type TABLE_EXPORT/TABLE/PROCACT_INSTANCE
ORA-39083: Object type PROCACT_INSTANCE failed to create with error:
ORA-31625: Schema MUSER is needed to import this object, but is unaccessible
ORA-01435: user does not exist
Starting "TEST"."SYS_IMPORT_FULL_01": test/******** remap_table=TESTUSER.T_BOOK_518:TEST.T_BOOK_518 dumpfile=OA186751.dmp logfile=OA186751_imp_t_BOOK.log DIRECTORY=DUMPDIR
Processing object type TABLE_EXPORT/TABLE/PROCACT_INSTANCE
ORA-39083: Object type PROCACT_INSTANCE failed to create with error:
ORA-31625: Schema MUSER is needed to import this object, but is unaccessible
ORA-01435: user does not exist
Starting "TEST"."SYS_IMPORT_TABLE_01": test/******** TABLES=TESTUSER.T_BOOK_518,TESTUSER.T_BOOK_SETTLE_INFO_518,TESTUSER.T_CAR_SETTLE_518,TESTUSER.T_BOOK_ABNORMAL_518,TESTUSER.T_BOOK_REFUND_518,MUSER.T_PAYFOR_TRADE_6MER0504 dumpfile=OA186751.dmp logfile=OA186751_imp.log DIRECTORY=DUMPDIR
Processing object type TABLE_EXPORT/TABLE/TABLE
ORA-39083: Object type TABLE:"MUSER"."T_PAYFOR_TRADE_6MER0504" failed to create with error:
ORA-01918: user 'MUSER' does not exist
Failing sql is:
上面涉及两点,1、Schema变了-> remap_schema来转换,2、TABLE要指定Schema
下面将MUSER用户下备份的表恢复到TEST2用户下
[oracle@localhost dump_dir]$ impdp test2/test123 remap_schema=MUSER:TEST2 tables=MUSER.T_PAYFOR_TRADE_6MER0504 directory=DUMPDIR dumpfile=OA186751.dmp logfile=OA186751_MUSER.log
Import: Release 11.2.0.1.0 - Production on Mon May 21 19:33:24 2018
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Master table "TEST2"."SYS_IMPORT_TABLE_01" successfully loaded/unloaded
Starting "TEST2"."SYS_IMPORT_TABLE_01": test2/******** remap_schema=MUSER:TEST2 tables=MUSER.T_PAYFOR_TRADE_6MER0504 directory=DUMPDIR dumpfile=OA186751.dmp logfile=OA186751_MUSER.log
Processing object type TABLE_EXPORT/TABLE/TABLE
Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
. . imported "TEST2"."T_PAYFOR_TRADE_6MER0504" 82.31 KB 567 rows
Job "TEST2"."SYS_IMPORT_TABLE_01" successfully completed at 19:33:32
再对另外一个Schema进行IMPDP就可以了。。。
错误例子:
下面这个首先关键字就没选好,只是想把表从一个用户导入到另外一个用户,而remap_table是修改表名称
--impdp test/test123 DIRECTORY=DUMPDIR remap_table=MUSER.T_PAYFOR_TRADE_6MER0504:TEST.T_PAYFOR_TRADE_6MER0504 dumpfile=OA186751.dmp logfile=OA186751_imp.log
参考及示例出处:
https://blog.csdn.net/e_wsq/article/details/78374020
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
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
跨schema只导出导入表并重命名的标准方式如下
expdp时tables写上schema.表名并用逗号隔开
impdp时需要remap_schema, tables可写可不写,remap_table冒号前面的表名加上schema,冒号后面的表名不加schema
expdp system/123456 tables=t01.test101,t01.test102,t01.test103 directory=DATA_PUMP_DIR dumpfile=t011.dbf
一个案例
A服务器导出用户ESB的一张分区表ESB_LOG
expdp system/123456 directory=DATA_PUMP_DIR dumpfile=ESB_LOG.dmp logfile=ESB_LOG.log tables=ESB.ESB_LOG
导入到B服务器的part用户,表名改为ESB_LOG2(加了tables=ESB.ESB_LOG,其实加不加无所谓,反正ESB_LOG.dm就是只有一张表ESB.ESB_LOG)
impdp system/123456 directory=DATA_PUMP_DIR dumpfile=ESB_LOG.dmp logfile=ESB_LOG2.log tables=ESB.ESB_LOGremap_schema=ESB:part remap_tablespace=ESB07:part,ESB08:part,ESB09:part,ESB10:part,ESB11:part,ESB12:part,ESB:part remap_table=ESB.ESB_LOG:ESB_LOG2