DATAPUMP如何导出时使用exclude排除表

发布时间:2021-11-10 09:50:01 作者:小新
来源:亿速云 阅读:519

这篇文章主要介绍了DATAPUMP如何导出时使用exclude排除表,具有一定借鉴价值,感兴趣的朋友可以参考下,希望大家阅读完这篇文章之后大有收获,下面让小编带着大家一起了解一下。

一、问题描述

       有个小小需求,要从生产数据库上导数据到测试库,问题是有张大表(30G)不需要导出到测试环境,所以要使用到expdp中’exclude’参数。但是在使用过程中还是碰到一点点question。

二、操作过程

1.根据expdp -help 信息中得知exclude参数的for example如下:

EXCLUDE                                

Exclude specific object types.         

For example, EXCLUDE=SCHEMA:"='HR'”.     

当然 = 也可以替换成 in ( ) 或 like ‘%..%’这种方式,如:exclude=index:”like ‘emp%’" ,也可以只给object types,如: exclude=VIEW,PACKAGE, FUNCTION

官方文档给出的Syntax是

EXCLUDE=object_type[:name_clause] [, …]

按照上面的例子,我推断出exclude参数针对表的使用

exclude=table:”=‘table name’”

2.执行语句报错,此处说明语法有问题,最终查询到原来是由于没有加转义符。

[oracle@rac2 ~]$ expdp cloan/xxxx DIRECTORY=backup DUMPFILE=cloan_20170713.dmp log=cloan_20170713.log  exclude=table:"='WSCT_DATA'" compression=all

LRM-00116: syntax error at 'table:' following '='

3.修改,增加转义符后执行成功

[oracle@rac2 ~]$ expdp cloan/xxxx DIRECTORY=backup DUMPFILE=cloan_20170713.dmp log=cloan_20170713.log  EXCLUDE=TABLE:\"= \'WSCT_DATA\'\" compression=all

Export: Release 11.2.0.4.0 - Production on Thu Jul 13 10:17:50 2017

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

Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production

With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,

Data Mining and Real Application Testing options

Legacy Mode Active due to the following parameters:

Legacy Mode Parameter: "log=cloan_20170713.log" Location: Command Line, Replaced with: "logfile=cloan_20170713.log"

Legacy Mode has set reuse_dumpfiles=true parameter.

Starting "CLOAN"."SYS_EXPORT_SCHEMA_02":  cloan/******** DIRECTORY=backup DUMPFILE=cloan_20170713.dmp logfile=cloan_20170713.log EXCLUDE=TABLE:"= 'WSCT_DATA'" compression=all reuse_dumpfiles=true

Estimate in progress using BLOCKS method...

Processing object type SCHEMA_EXPORT/TABLE/TABLE_DATA

… … 

Dump file set for CLOAN.SYS_EXPORT_SCHEMA_02 is:

  /backup/cloan_20170713.dmp

Job "CLOAN"."SYS_EXPORT_SCHEMA_02" successfully completed at Thu Jul 13 10:19:18 2017 elapsed 0 00:01:27

4.导入到测试环境成功

[oracle@testdb backup]$  impdp cloancp/xxxx DIRECTORY=backup DUMPFILE=cloan_20170713.dmp remap_schema=cloan:cloancp remap_tablespace=cloan:newcloan;

Import: Release 11.2.0.4.0 - Production on Thu Jul 13 10:45:30 2017

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

Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

Master table "CLOANCP"."SYS_IMPORT_FULL_01" successfully loaded/unloaded

Starting "CLOANCP"."SYS_IMPORT_FULL_01":  cloancp/******** DIRECTORY=backup DUMPFILE=cloan_20170713.dmp remap_schema=cloan:cloancp remap_tablespace=cloan:newcloan

Processing object type SCHEMA_EXPORT/PRE_SCHEMA/PROCACT_SCHEMA

Processing object type SCHEMA_EXPORT/SEQUENCE/SEQUENCE

Processing object type SCHEMA_EXPORT/TABLE/TABLE

Processing object type SCHEMA_EXPORT/TABLE/TABLE_DATA

…...

Processing object type SCHEMA_EXPORT/TABLE/COMMENT

Processing object type SCHEMA_EXPORT/TABLE/INDEX/INDEX

Processing object type SCHEMA_EXPORT/TABLE/CONSTRAINT/CONSTRAINT

Processing object type SCHEMA_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS

Processing object type SCHEMA_EXPORT/TABLE/TRIGGER

Processing object type SCHEMA_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS

Job "CLOANCP"."SYS_IMPORT_FULL_01" completed with 4 error(s) at Thu Jul 13 10:46:34 2017 elapsed 0 00:01:04

感谢你能够认真阅读完这篇文章,希望小编分享的“DATAPUMP如何导出时使用exclude排除表”这篇文章对大家有帮助,同时也希望大家多多支持亿速云,关注亿速云行业资讯频道,更多相关知识等着你来学习!

推荐阅读:
  1. 使用navicat工具导出mysql表的步骤
  2. 怎么使用Datapump中的EXCLUDE/INCLUDE

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

datapump exclude

上一篇:springboot中如何使用freemarker页面模版

下一篇:Django中的unittest应用是什么

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》