Oracle数据泵使用详解(二)

2014-11-24 16:20:18 · 作者: · 浏览: 1
ba
SQL> create directory dir as '/home/oracle/';
SQL> grant read,write on directory dir to system;
$expdp system/oracle directory=dir dumpfile=data.dmp schemas=a logfile=data.log
impdp
导入a用户所有数据到b,并且转换表空间a为b:
SQL> conn sys / as sysdba
SQL> create directory dir as '/home/oracle/';
SQL> grant read,write on directory dir to system;
$impdp system/oracle directory=dir dumpfile=data.dmp remap_tablespace=a:b remap_schema=a:b logfile=data.log
解释:
remap_schema=a:b 将数据的schema从a 转换为b
remap_tablespace=a:b 将数据的tablespace 从a 转换为b
注意:如果oracle是10g的,要加参数 EXCLUDE=TABLE_STATISTICS 选项将 table_statistics 对象过滤。 否则会出现数据泵导入中table_statistics长时间等待、用impdp 导入,检查 table_statistics 时等待了N长时间
总结:执行impdp时无需创建b用户,在导入时会自动创建并改名用户a为b(拥有a的所有权限等),自动设置默认表空间为转换后的表空间b。如果有多个表空间需要转换,则使用多个remap_tablespace=源:目标字段。
此种方法只限于支持oracle10g以上版本。
数据泵导入中table_statistics长时间等待问题
用impdp 导入,检查 table_statistics 时等待了N长时间。
网上说这是oracle 10G impdp 的一个bug,命令中若定义了 remap_schema 项,也就是原用户名和导入的用户名不一致,则会有这个问题。
网上提供的解决办法是,让导入和导出的用户名一致,或者在导入时通过 EXCLUDE=TABLE_STATISTICS 选项将 table_statistics 对象过滤。