码迷,mamicode.com
首页 > 数据库 > 详细

ORACLE expdp导出/导入以XX开头的所有表

时间:2017-05-05 15:34:12      阅读:246      评论:0      收藏:0      [点我收藏+]

标签:oracle   tables   expdp   

场景:有2个oracle用户,userA默认表空间tablespaceA, userB默认表空间tablespaceB。

        现在需要将userA中的系统表(该用户表空间中以SYS开头的表)导出到userB中,将userB的系统表覆盖,但不覆盖userB的业务表。方法如下:

        导出userA用户schema中SYS开头的表,使用tables=SYS%

expdp userA/password  directory=TMP_BAK dumpfile=userA-170504-expdp-tab.dmp  logfile=userA-170504-expdp-tab.log tables=SYS%

        若只需导出某几张表,则使用tables=table1,table2         

expdp userA/password  directory=TMP_BAK dumpfile=userA-170504-expdp-tab02.dmp  logfile=userA-170504-expdp-tab02.log tables=table1,table2

         


         将导出的dmp文件导入到userB用户的schema中。

         需要注意此处SCHEMA与表对应的TABLESPACE已经发生改变,并且原userB的表空间中已经存在SYS表。故导入时需要加上以下几个参数:

        ①remap_schema指定源SCHEMA与目的SCHEMA。

        ②remap_tablespace指定源TABLESPACE与目的TABLESPACE。

        ③ table_exists_action=replace将重名表进行覆盖。


        导入前注意先备份userB的数据,避免导出出错造成数据丢失。

expdp userB/password  directory=TMP_BAK dumpfile=userB-170504-expdp.dmp  logfile=userB-170504-expdp.log

        

         正式将SYS开头的表导入userB用户中。

impdp userB/password  directory=TMP_BAK dumpfile=userA-170504-expdp-tab.dmp  remap_schema=userA:userB REMAP_TABLESPACE=tablespaceA:tablespaceB TABLE_EXISTS_ACTION=REPLACE logfile=userB-0504-impdp-tab.log


本文出自 “一年后回头看看” 博客,请务必保留此出处http://cubix.blog.51cto.com/7251166/1922222

ORACLE expdp导出/导入以XX开头的所有表

标签:oracle   tables   expdp   

原文地址:http://cubix.blog.51cto.com/7251166/1922222

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!