通过impdp做数据库迁移遇到的问题总结

初始的时候通过两个库之间直接转储数据,命令如下:

在要导入的库的OS下执行:

[oracle@qqdb auto_dmp]$ impdp tests/tests tables=ABC directory=dump_dir logfile=logfile.log network_link=crm_test table_exists_action=APPEND

[@more@]Import: Release 10.2.0.1.0 - 64bit Production on Saturday, 30 October, 2010 2:28:40

Copyright (c) 2003, 2005, Oracle. All rights reserved.

Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bit Production
With the Partitioning, OLAP and Data Mining options
Starting "TESTS"."SYS_IMPORT_TABLE_01": tests/******** tables=ABC directory=dump_dir logfile=logfile.log network_link=crm_test table_exists_action=APPEND
Estimate in progress using BLOCKS method...
Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
Total estimation using BLOCKS method: 3 MB
Processing object type TABLE_EXPORT/TABLE/TABLE
ORA-39083: Object type TABLE failed to create with error:
ORA-00959: tablespace 'CRMREPORT' does not exist
Failing sql is:
CREATE TABLE "SCOTT"."ABC" ("A" CLOB, "B" BLOB, "C" VARCHAR2(10)) PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING STORAGE(INITIAL 1048576 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT) TABLESPACE "CRMREPORT" LOB ("A") STORE AS ( TABLESPACE "CRMREPORT" ENABLE STORAGE IN ROW CHUNK 8192 PCTVERSION 10 NOCA
Job "TESTS"."SYS_IMPORT_TABLE_01" completed with 1 error(s) at 02:28:56

[oracle@qqdb auto_dmp]$

因为我已经在目标库内创建了对应的ABC表,而且我导入的时候TABLE_EXISTS_ACTION设置的为APPEND,按理说应该直接将数据append进去的,可是结果却是还要重新创建表,但是此时有LOB字段的存在,所以加入如下参数:

REMAP_TABLESPACE=CRMREPORT:USERS

此时重新执行:

[oracle@qqdb auto_dmp]$ impdp tests/tests tables=ABC directory=dump_dir logfile=logfile.log network_link=crm_test table_exists_action=APPEND REMAP_TABLESPACE=CRMREPORT:USERS

Import: Release 10.2.0.1.0 - 64bit Production on Saturday, 30 October, 2010 2:30:57

Copyright (c) 2003, 2005, Oracle. All rights reserved.

Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bit Production
With the Partitioning, OLAP and Data Mining options
Starting "TESTS"."SYS_IMPORT_TABLE_01": tests/******** tables=ABC directory=dump_dir logfile=logfile.log network_link=crm_test table_exists_action=APPEND REMAP_TABLESPACE=CRMREPORT:USERS
Estimate in progress using BLOCKS method...
Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
Total estimation using BLOCKS method: 3 MB
Processing object type TABLE_EXPORT/TABLE/TABLE
ORA-39152: Table "SCOTT"."ABC" exists. Data will be appended to existing table but all dependent metadata will be skipped due to table_exists_action of append
. . imported "SCOTT"."ABC" 1 rowsJob "TESTS"."SYS_IMPORT_TABLE_01" completed with 1 error(s) at 02:32:12

此时可以看到已经转入了数据。

因为在线impdp的时候通过database link导入的时候,只能对应的 导入和database link对应的用户里面,如果想要导入其他的用户可以指定如下参数:

REMAP_SCHEMA=SCOTT:TESTS

执行结果如下:

[oracle@qqdb auto_dmp]$ impdp tests/tests tables=ABC directory=dump_dir logfile=logfile.log network_link=crm_test table_exists_action=APPEND REMAP_TABLESPACE=CRMREPORT:USERS REMAP_SCHEMA=SCOTT:TESTS

Import: Release 10.2.0.1.0 - 64bit Production on Saturday, 30 October, 2010 2:33:26

Copyright (c) 2003, 2005, Oracle. All rights reserved.

Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bit Production
With the Partitioning, OLAP and Data Mining options
Starting "TESTS"."SYS_IMPORT_TABLE_01": tests/******** tables=ABC directory=dump_dir logfile=logfile.log network_link=crm_test table_exists_action=APPEND REMAP_TABLESPACE=CRMREPORT:USERS REMAP_SCHEMA=SCOTT:TESTS
Estimate in progress using BLOCKS method...
Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
Total estimation using BLOCKS method: 3 MB
Processing object type TABLE_EXPORT/TABLE/TABLE
ORA-39152: Table "TESTS"."ABC" exists. Data will be appended to existing table but all dependent metadata will be skipped due to table_exists_action of append
. . imported "TESTS"."ABC" 1 rowsJob "TESTS"."SYS_IMPORT_TABLE_01" completed with 1 error(s) at 02:34:41

请使用浏览器的分享功能分享到微信等