oracle 不同表空间的数据迁移

本文介绍了如何在Oracle数据库中使用expdp和impdp工具迁移用户数据,特别是在不同表空间之间的转换。针对Oracle 10g及以上版本,可以通过expdp导出数据,然后用impdp导入时指定remap_tablespace和remap_schema参数实现表空间和用户名称的转换。对于Oracle 9i到10g的数据迁移,可能需要更复杂的步骤,包括创建新表空间、用户及权限分配,但这种方法可能无法确保所有表都能成功迁移。
摘要由CSDN通过智能技术生成

1.expdp和impdp

expdp
假设sglaw用户的默认表空间是users,导出用户sglaw所有数据:

SQL> conn / as sysdba
SQL> create directory dir as '/home/oracle/';
SQL> grant read,write on directory dir to system;

$expdp system/oracle directory=dir dumpfile=sglaw.dmp schemas=sglaw logfile=sglaw.log

 

impdp
导入sglaw用户所有数据到gh,并且转换表空间users为gh:

SQL> conn / as sysdba
SQL> create directory dir as '/home/oracle/';
SQL> grant read,write on directory dir to system;

$impdp system/oracle directory=dir dumpfile=sglaw.dmp remap_tablespace=users:gh remap_schema=sglaw:gh logfile=sglaw.log

 

总结:执行impdp时无需创建gh用户,在导入时会自动创建并改名用户sglaw为gh(拥有sglaw的所有权限等),自动设置默认表空间为转换后的表空间gh。如果有多个表空间需要转换,则使用多个remap_tablespace=源:目标 字段。

此种方法只限于支持oracle10g以上版本。

 

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值