impdp 中要是没有remap方式,那么个人认为datapump 将是一个死板的工具。
remap_table方式
语法格式:REMAP_TABLE=[schema.]old_tablename[.partition]:new_tablename
在hr 模式中根据employees 创建如下一张表。
SQL>create table emp as select * from employees where 1=2;
执行导入操作,tables 中指定了employees,因为dumpfile table.dmp
中除了employees 表中的数据以外,还有其他表的数据。关键是remap_table
参数的使用把employees 表中的数据从映射到emp 表,并且我们还使用了
conntent=data_only 参数,因为emp表已经存在,我们需要导入的只是数据。
C:\Users\hello>impdp hr/hr tables=employees remap_table=employees:emp dumpfile=dmp_dir:table.dmp nologfile=yes content=data_only
Import: Release 11.2.0.1.0 - Production on Sun Jun 24 09:35:22 2012
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 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Master table "HR"."SYS_IMPORT_TABLE_01" successfully loaded/unloaded
Starting "HR"."SYS_IMPORT_TABLE_01": hr/******** tables=employees remap_table=employees:emp dumpfile=dmp_dir:table.dmp nologfile=yes content=data_only
Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
. . imported "HR"."EMP" 16.80 KB 107 rows
Job "HR"."SYS_IMPORT_TABLE_01" successfully completed at 09:35:26
导入成功,下面确定数据是否存在于remap_table 参数指定的表中。
SQL>select count(*) from emp;
COUNT(*)
----------