Oracle其實在11.1.0.6中已經推出了這個功能,不過11.1.0.6中還存在bug。這裡簡單介紹一下11.2中的REMAP_TABLE功能。
看一個簡單的例子:
SQL> select * from v$version;
BANNER
--------------------------------------------------------------------------------
Oracle Database11gEnterprise Edition Release11.2.0.1.0 - 64bit Production
PL/SQL Release 11.2.0.1.0 - Production
CORE 11.2.0.1.0 Production
TNS for Linux: Version 11.2.0.1.0 - Production
NLSRTL Version 11.2.0.1.0 - Production
SQL> create table t
2 (id number,
3 name varchar2(30));
表已建立。
SQL> insert into t
2 select rownum, tname
3 from tab;
已建立11行。
SQL> commit;
提交完成。
SQL> create index ind_t_id
2 on t (id);
索引已建立。
下面匯出T表:
SQL> host expdp yangtk/yangtk directory=d_output dumpfile=t.dp tables=t
Export: Release11.2.0.1.0 - Production on星期五6月4 23:31:50 2010
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
串連到: Oracle Database11gEnterprise Edition Release11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
啟動"YANGTK"."SYS_EXPORT_TABLE_01": yangtk/******** directory=d_output dumpfile=t.dp tables=t
正在使用BLOCKS方法進行估計...
處理物件類型TABLE_EXPORT/TABLE/TABLE_DATA
使用BLOCKS方法的總估計: 128 KB
處理物件類型TABLE_EXPORT/TABLE/TABLE
處理物件類型TABLE_EXPORT/TABLE/INDEX/INDEX
處理物件類型TABLE_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS
. .匯出了"YANGTK"."T" 5.562 KB 11行
已成功載入/卸載了主表"YANGTK"."SYS_EXPORT_TABLE_01"
******************************************************************************
YANGTK.SYS_EXPORT_TABLE_01的轉儲檔案集為:
/home/oracle/t.dp
作業"YANGTK"."SYS_EXPORT_TABLE_01"已於23:31:59成功完成
利用REMAP_TABLE將匯入表重新對應到T_NEW表中:
SQL> host impdp yangtk/yangtk directory=d_output dumpfile=t.dp remap_table=t:t_new
Import: Release11.2.0.1.0 - Production on星期五6月4 23:32:19 2010
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
串連到: Oracle Database11gEnterprise Edition Release11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
已成功載入/卸載了主表"YANGTK"."SYS_IMPORT_FULL_01"
啟動"YANGTK"."SYS_IMPORT_FULL_01": yangtk/******** directory=d_output dumpfile=t.dp remap_table=t:t_new
處理物件類型TABLE_EXPORT/TABLE/TABLE
處理物件類型TABLE_EXPORT/TABLE/TABLE_DATA
. .匯入了"YANGTK"."T_NEW" 5.562 KB 11行
處理物件類型TABLE_EXPORT/TABLE/INDEX/INDEX
ORA-31684:物件類型INDEX:"YANGTK"."IND_T_ID"已存在
處理物件類型TABLE_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS
ORA-39111:跳過從屬物件類型INDEX_STATISTICS,基本物件類型INDEX:"YANGTK"."IND_T_ID"已存在