Chinaunix首页 | 论坛 | 博客
  • 博客访问: 650491
  • 博文数量: 168
  • 博客积分: 2928
  • 博客等级: 中校
  • 技术积分: 1904
  • 用 户 组: 普通用户
  • 注册时间: 2010-01-04 09:56
文章分类

全部博文(168)

文章存档

2010年(168)

我的朋友

分类: Oracle

2010-06-08 11:39:38

其实在11.1.0.6中已经推出了这个功能,不过11.1.0.6中还存在bug。这里简单介绍一下11.2中的REMAP_TABLE功能。

Oracle新特性——数据泵(六):http://yangtingkun.itpub.net/post/468/473311

1106版本中数据泵导入REMAP_TABLE无效:http://yangtingkun.itpub.net/post/468/473037

 

 

看一个简单的例子:

SQL> select * from v$version;

BANNERITPUB个人空间q'dA4?5EM
--------------------------------------------------------------------------------
{I ~l]xr*D2e z9266282Oracle Database11gEnterprise Edition Release11.2.0.1.0 - 64bit ProductionITPUB个人空间N'}1[P!Q.|
PL/SQL Release 11.2.0.1.0 - Production
*_ zZi7yi4a"`9266282CORE    11.2.0.1.0      Production
%x GFHoN E9266282TNS for Linux: Version 11.2.0.1.0 - ProductionITPUB个人空间8[f2j o_/[0W
NLSRTL Version 11.2.0.1.0 - Production

SQL> create table tITPUB个人空间N9wm8dl1_
  2  (id number,
{ p3m ^i%Jl9266282  3  name varchar2(30));

表已创建。

SQL> insert into tITPUB个人空间L FZctI
  2  select rownum, tnameITPUB个人空间9A[G!OH'd+l y
  3  from tab;

已创建11行。

SQL> commit;

提交完成。

SQL> create index ind_t_id
"?`'^0|h Z9266282  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星期五64 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 ProductionITPUB个人空间Vh2kC.P6s&{ A
With the Partitioning, OLAP, Data Mining and Real Application Testing options
3]0}dV]wZa*@9266282
启动"YANGTK"."SYS_EXPORT_TABLE_01":  yangtk/******** directory=d_output dumpfile=t.dp tables=tITPUB个人空间^2guC\;[(zNV
正在使用BLOCKS方法进行估计...
|m Vz6G/v5A"b4|+N9266282
处理对象类型TABLE_EXPORT/TABLE/TABLE_DATAITPUB个人空间?({I'A6x'lvbN*C
使用BLOCKS方法的总估计: 128 KB
L0d+jCN#]9266282
处理对象类型TABLE_EXPORT/TABLE/TABLE
[(M.sPoii$X)] Kx9266282
处理对象类型TABLE_EXPORT/TABLE/INDEX/INDEX
yLy7OW!e#F9266282
处理对象类型TABLE_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS
I s4G&Nx p"M h3\X9266282. .
导出了"YANGTK"."T"                                5.562 KB      11ITPUB个人空间G}%]S2L/p!i0V
已成功加载/卸载了主表"YANGTK"."SYS_EXPORT_TABLE_01"
L-nQ|"R1@9266282******************************************************************************
4NbX2u5d#P9266282YANGTK.SYS_EXPORT_TABLE_01
的转储文件集为:
+a?Q'G(F6gRdeA9266282  /home/oracle/t.dp
sQ#XF^$hy9266282
作业"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星期五64 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
0Qa,L)e:H,e'm9266282With the Partitioning, OLAP, Data Mining and Real Application Testing optionsITPUB个人空间C9x~2i!R#b5i&t
已成功加载/卸载了主表"YANGTK"."SYS_IMPORT_FULL_01"
FP6NMsW!w8L$h9266282
启动"YANGTK"."SYS_IMPORT_FULL_01":  yangtk/******** directory=d_output dumpfile=t.dp remap_table=t:t_new
H6kK0ENe+o4d9266282
处理对象类型TABLE_EXPORT/TABLE/TABLE
z[.AB Y5C'^&T-?9266282
处理对象类型TABLE_EXPORT/TABLE/TABLE_DATAITPUB个人空间VIT9\q_9d
. .
导入了"YANGTK"."T_NEW"                            5.562 KB      11
L`r)V&l*Hm9266282
处理对象类型TABLE_EXPORT/TABLE/INDEX/INDEXITPUB个人空间2|8l?&H$i#h"b'~
ORA-31684:
对象类型INDEX:"YANGTK"."IND_T_ID"已存在
W;z` } F:I9266282
处理对象类型TABLE_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS
8w/u!F;MrB9266282ORA-39111:
跳过从属对象类型INDEX_STATISTICS,基本对象类型INDEX:"YANGTK"."IND_T_ID"已存在
;@ PoU8CG*@9266282
作业"YANGTK"."SYS_IMPORT_FULL_01"已经完成,但是有2个错误(23:32:22完成)

ITPUB个人空间{9A%jw EX
SQL> select count(*) from t_new;

  COUNT(*)ITPUB个人空间;^Q8m{$L\'m[u
----------
2b#P9hjL z:GC9266282        11

REMAP_TABLE成功,T_NEW表创建,而且数据已经导入,不过可以看到,索引并没有别创建,不过这并不难理解,因为同名索引已经被创建,因此索引显然不能导入,下面删除索引:

SQL> drop table t_new purge;

表已删除。

SQL> drop index ind_t_id;

索引已删除。

再次执行导入操作:

SQL> host impdp yangtk/yangtk directory=d_output dumpfile=t.dp remap_table=t:t_new

Import: Release11.2.0.1.0 - Production on星期五64 23:32:54 2010

Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.

连接到: Oracle Database11gEnterprise Edition Release11.2.0.1.0 - 64bit Production
(B zp-j1J2nw9266282With the Partitioning, OLAP, Data Mining and Real Application Testing options
c.^"h d]j^9266282
已成功加载/卸载了主表"YANGTK"."SYS_IMPORT_FULL_01"ITPUB个人空间VqZ"}\J
启动"YANGTK"."SYS_IMPORT_FULL_01":  yangtk/******** directory=d_output dumpfile=t.dp remap_table=t:t_new
zZ.j R ]d a%]]8f9266282
处理对象类型TABLE_EXPORT/TABLE/TABLEITPUB个人空间-j1j#v?k)nQ)hHD}
处理对象类型TABLE_EXPORT/TABLE/TABLE_DATA
d4R+\)|| F9266282. .
导入了"YANGTK"."T_NEW"                            5.562 KB      11
7m:mA aP*@6uYa,V9266282
处理对象类型TABLE_EXPORT/TABLE/INDEX/INDEXITPUB个人空间;~+Y pMj9bF}
处理对象类型TABLE_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICSITPUB个人空间cV PP'HjwZ!Xl
作业"YANGTK"."SYS_IMPORT_FULL_01"已于23:32:58成功完成

ITPUB个人空间&{x1UZy*^pD{4P~4V
SQL> select table_name, index_nameITPUB个人空间 fh*m-f7_-UiQ
  2  from user_indexes
$n%?e S B1}h6|9266282  3  where index_name = 'IND_T_ID';

TABLE_NAME                     INDEX_NAME
m hd:J(Nj.S_9266282------------------------------ ------------------------------
(V/nDbCU q9266282T                              IND_T_ID

索引也成功导入,但是检查后发现,索引仍然创建到T表上,并没有因为使用了REMAP_TABLE而建立在T_NEW表中。

因此,至少在11.2.0.1中,REMAP_TABLE只对表和数据有效,而对索引无效,而且使用REMAP_TABLE对于原表仍然存在的情况下要小心,因为REMAP_TABLE操作很可能导致源表发生导入操作,导致一些非预期的对象被导入,比如:

SQL> alter table t add check (id > 0);

表已更改。

SQL> host expdp yangtk/yangtk directory=d_output dumpfile=t.dp tables=t reuse_dumpfiles=y

Export: Release11.2.0.1.0 - Production on星期五64 23:51:13 2010

Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.

连接到: Oracle Database11gEnterprise Edition Release11.2.0.1.0 - 64bit Production
+ao T0X"U}9266282With the Partitioning, OLAP, Data Mining and Real Application Testing options
3A!xRn+][v?9x9266282
启动"YANGTK"."SYS_EXPORT_TABLE_01":  yangtk/******** directory=d_output dumpfile=t.dp tables=t reuse_dumpfiles=y
(zsL3Zy$XE9266282
正在使用BLOCKS方法进行估计...ITPUB个人空间b-f)E1`%A)k7g#K
处理对象类型TABLE_EXPORT/TABLE/TABLE_DATA
d*q4bQ*M5L9266282
使用BLOCKS方法的总估计: 128 KBITPUB个人空间E+cM qb Qb
处理对象类型TABLE_EXPORT/TABLE/TABLE
z*`!lTj\YcSw9266282
处理对象类型TABLE_EXPORT/TABLE/INDEX/INDEXITPUB个人空间4{.~._2p'?I'f
处理对象类型TABLE_EXPORT/TABLE/CONSTRAINT/CONSTRAINTITPUB个人空间*R3p:J9zj9a%}[0d,I
处理对象类型TABLE_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS
|3xNl9sN#B9266282. .
导出了"YANGTK"."T"                                5.562 KB      11ITPUB个人空间bW%}k {a8S
已成功加载/卸载了主表"YANGTK"."SYS_EXPORT_TABLE_01"ITPUB个人空间2@%iq4f"Y\U$\Ef
******************************************************************************
rTu-~g`4N At9266282YANGTK.SYS_EXPORT_TABLE_01
的转储文件集为:
W u6x(L)Qz2vq9266282  /home/oracle/t.dp
"w,~#Ua!R)b5J:S]9266282
作业"YANGTK"."SYS_EXPORT_TABLE_01"已于23:51:23成功完成


Jpd0h|#_)}H+x9266282SQL> drop table t_new purge;

表已删除。

SQL> host impdp yangtk/yangtk directory=d_output dumpfile=t.dp remap_table=t:t_new

Import: Release11.2.0.1.0 - Production on星期五64 23:55:51 2010

Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.

连接到: Oracle Database11gEnterprise Edition Release11.2.0.1.0 - 64bit Production
!Nw ](i3V9266282With the Partitioning, OLAP, Data Mining and Real Application Testing options
h0NO4s}{(jIP3T9266282
已成功加载/卸载了主表"YANGTK"."SYS_IMPORT_FULL_01"ITPUB个人空间1kMRc0J |$W R
启动"YANGTK"."SYS_IMPORT_FULL_01":  yangtk/******** directory=d_output dumpfile=t.dp remap_table=t:t_new
dTKU [Th6P u9266282
处理对象类型TABLE_EXPORT/TABLE/TABLEITPUB个人空间4U n8nZx(I ~
处理对象类型TABLE_EXPORT/TABLE/TABLE_DATAITPUB个人空间"M `.[y`5fVr
. .
导入了"YANGTK"."T_NEW"                            5.562 KB      11ITPUB个人空间"`(Gm{+qK W
处理对象类型TABLE_EXPORT/TABLE/INDEX/INDEXITPUB个人空间P2gQ(T0R'T#N^Q;sj
ORA-31684:
对象类型INDEX:"YANGTK"."IND_T_ID"已存在ITPUB个人空间U;w/T7BH.O)T1BO
处理对象类型TABLE_EXPORT/TABLE/CONSTRAINT/CONSTRAINTITPUB个人空间G gKsS6lbX
处理对象类型TABLE_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICSITPUB个人空间"kFq1u5H7O
ORA-39111:
跳过从属对象类型INDEX_STATISTICS,基本对象类型INDEX:"YANGTK"."IND_T_ID"已存在ITPUB个人空间0}6?iw-goP6H7{J
作业"YANGTK"."SYS_IMPORT_FULL_01"已经完成,但是有2个错误(23:55:55完成)

ITPUB个人空间:W^C U)n
SQL> col search_condition format a20
s;S&rfyg9W9266282SQL> select table_name, constraint_name, search_condition
:V!GB$b1cQ}7\,k9266282  2  from user_constraints
9`|,XaMO2OT9266282  3  where table_name = 'T';

TABLE_NAME                     CONSTRAINT_NAME                SEARCH_CONDITIONITPUB个人空间cy S2j"g R8l
------------------------------ ------------------------------ --------------------
@4i{P)v6S$P9266282T                              SYS_C0011261                   id > 0
2qmS+w u P V8K9266282T                              SYS_C0011277                   id > 0

在这个例子中,就由于约束是系统名称,导致在执行REMAP_TABLE导入后,同样的约束在源表上重复建立。

阅读(2219) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~