数据泵导出导入工具的使用

一.导出工具expdp 示例

  a.创建目录

     create directory  dump_dir  as 'D:\dump';

  b.赋予用户scott对目录dump_dir的读写权限

  grant read,writeon directory dump_dir to scott;

 c.1.导出表

   expdp scott/tiger@demo directory = dump_dir dumpfile = tab.dmp logfile = tab.log        tables = emp,dept

   2.导出方案

   expdp scott/tiger@demo directory = dump_dir dumpfile = scott.dmp logfile = scott.log         schemas = scott

   3.导出表空间

   expdp scott/tiger@demo directory = dump_dir dumpfile = tablespace.dmp logfile = tablespace.log tablespaces=user01,user02

   导出数据库

  expdp scott/tiger@demo directory = dump_dir dumpfile = full.dmp logfile = full.log full=y

二.导入工具impdp示例

  1.导入表

    同一用户导入

   impdp scott/tiger@demo directory = dump_dir dumpfile = tab.dmp tables = emp,dept

    不同用户导入

        impdp system/manager@demo directory = dump_dir dumpfile = tab.dmp tables = emp,dept remap_schema = scott:system

      2. 导入方案

      impdp scott/tiger@demo directory = dump_dir dumpfile = scott.dmp schemas = scott

   impdp system/manager@demo directory = dump_dir dumpfile = scott.dmp schemas = scott remap_schema = scott:system

  3.导入表空间

   impdp scott/tiger@demo directory = dump_dir dumpfile = tablespace.dmp tablespaces = user01

  导入数据库

  impdp scott/tiger@demo directory = dump_dir dumpfile = full.dmp full = y

 

三.expdp常用参数

 1.content:该选项用于指定要导出的内容.默认值为ALL

        CONTENT={ALL| DATA_ONLY | METADATA_ONLY}

 

        expdp scott/tiger  schemas=scottcontent=all

        expdp scott/tiger tables=empcontent=data_only directory=dump_scott dumpfile=empdata.dmp(只导出对象数据)

        expdp scott/tiger tables=empcontent=metadata_only directory=dump_scott dumpfile=empmd.dmp(只有定义信息)

 

    2.estimate: 指定估算被导出表所占用磁盘空间分方法.默认值是blocks

 

        expdp scott/tiger directory=dump_scott dumpfile=dba_object.dmp tablespaces=users estimate=statistics

        expdp scott/tiger directory=dump_scott dumpfile=dba_object.dmp tablespaces=users estimate=blocks

 

    3.extimate_only:指定是否只估算导出作业所占用的磁盘空间,默认值为N

 

        expdp scott/tiger  schemas=scott estimate_only=y               

        设置为Y时,导出作用只估算对象所占用的磁盘空间,而不会执行导出作业,

        为N时,不仅估算对象所占用的磁盘空间,还会执行导出操作.

 

    4.exclude:该选项用于指定执行操作时释放要排除对象类型或相关对象

        exclude=view

        exclude=package

        exclude=index:"like 'EMP%'

        object_type用于指定要排除的对象类型,name_expr用于指定要排除的具体对象.exclude和include不能同时使用

        expdp scott/tiger  schemas=scott  exclude=view dumpfile=a9.dmp

 

        include = object_type[:"name_expr"]

    5.filesize:指定导出文件的最大尺寸,默认为,(表示文件尺寸没有限制)

       

    6.flashback_scn: 前提闪回功能开启

        expdp scott/tiger  tables=emp dumpfile=e2.dmp  flashback_scn=4284715

        如果闪回的时间点该对象结构发生变化,将报错(比如该对象没有创建或者ddl操作)

 

    7.flashback_time:指定导出特定时间点的表数据

        expdp scott/tiger DIRECTORY=dump DUMPFILE=a.dmp FLASHBACK_TIME="TO_TIMESTAMP(-08-2004 14:35:00’,’DD-MM-YYYY HH24:MI:SS’)"

 

        windows下:

        C:/>expdp scott/tiger DIRECTORY=dump_dir DUMPFILE=a.dmp

        flashback_time=/"TO_TIMESTAMP('06-04-2010 11:24:26','DD-MM-YYYY HH24:MI:SS')/"

 

    8.query导出查询得到的结果集

        query=scott.emp :"where deptno= 30 and sal > 3500"

   

    9.sample 使用该参数进行对导出的数据进行采样

        sample="scott"."emp":20

        expdp scott/tiger directory=dump_scott dumpfile=sam.dmp sample=30

   

    10.dumpfile 指定导出时的文件名

        dumpfile=scott_tb.dmp

        dumpfile=scott_tb_%u.dmp   %u 用于扩展导出的文件名,固定长度为个字符,从开始递增,使用并行导出时建议指定该参数

 

 

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值