设为首页 收藏本站
查看: 996|回复: 0

[经验分享] 【Oracle expdp 排除表参数】

[复制链接]

尚未签到

发表于 2018-9-23 11:14:18 | 显示全部楼层 |阅读模式
  【Oracle expdp 排除表参数】
  使用EXPDP逻辑备份工具的EXCLUDE选项可以指定那类数据库对象不被导出,EXPDP工具的前身EXP如果想要完成同样的任务非常的困难。我们以排除部分表为例看一下这个选项带给我们的便利。
  如果在命令行中完成备份,特殊字符的转义需要特别注意(我这里使用的是Linux操作系统)。
  1.EXPDP帮助中的描述信息
  ora10g@secDB /expdp$ expdp -help
  ……
  EXCLUDE   Exclude specific object types, e.g. EXCLUDE=TABLE:EMP.
  ……
  2.创建directory数据库对象,并将读写权限授予sec用户
  sys@ora10g> create or replace directory dump_dir as '/expdp';
  Directory created.
  sys@ora10g> grant read,write on directory dump_dir to sec;
  Grant succeeded.
  3.确认操作系统信息
  ora10g@secDB /expdp$ uname -a
  Linux secDB 2.6.18-128.el5 #1 SMP Wed Dec 17 11:41:38 EST 2008 x86_64 x86_64 x86_64 GNU/Linux
  4.在sec用户下创建几张表用于后续的测试
  创建三张表T1、T2和T3,每张表中初始化一条数据
  sec@ora10g> create table t1 (x int);
  sec@ora10g> insert into t1 values (1);
  sec@ora10g> create table t2 (x int);
  sec@ora10g> insert into t2 values (2);
  sec@ora10g> create table t3 (x int);
  sec@ora10g> insert into t3 values (3);
  sec@ora10g> commit;
  5.为了与后面的比较,先全用户导出
  ora10g@secDB /expdp$ rm -f sec.dmp sec.log
  ora10g@secDB /expdp$ expdp sec/sec directory=dump_dir dumpfile=sec.dmp logfile=sec.log

  Export:>  Copyright (c) 2003, 2005, Oracle.  All rights reserved.

  Connected to: Oracle Database 10g Enterprise Edition>  With the Partitioning, Oracle Label Security, OLAP and Data Mining Scoring Engine options
  Starting "SEC"."SYS_EXPORT_SCHEMA_01":  sec/******** directory=dump_dir dumpfile=sec.dmp logfile=sec.log
  Estimate in progress using BLOCKS method...
  Processing object type SCHEMA_EXPORT/TABLE/TABLE_DATA
  Total estimation using BLOCKS method: 192 KB
  Processing object type SCHEMA_EXPORT/USER
  Processing object type SCHEMA_EXPORT/SYSTEM_GRANT
  Processing object type SCHEMA_EXPORT/ROLE_GRANT
  Processing object type SCHEMA_EXPORT/DEFAULT_ROLE
  Processing object type SCHEMA_EXPORT/PRE_SCHEMA/PROCACT_SCHEMA
  Processing object type SCHEMA_EXPORT/TABLE/TABLE
  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/COMMENT
  . . exported "SEC"."T1"                                  4.914 KB       1 rows
  . . exported "SEC"."T2"                                  4.914 KB       1 rows
  . . exported "SEC"."T3"                                  4.914 KB       1 rows
  Master table "SEC"."SYS_EXPORT_SCHEMA_01" successfully loaded/unloaded
  ******************************************************************************
  Dump file set for SEC.SYS_EXPORT_SCHEMA_01 is:
  /expdp/sec.dmp
  Job "SEC"."SYS_EXPORT_SCHEMA_01" successfully completed at 09:59:32
  6.排除T1表进行备份
  ora10g@secDB /expdp$ rm -f sec.dmp sec.log
  ora10g@secDB /expdp$ expdp sec/sec directory=dump_dir dumpfile=sec.dmp logfile=sec.log EXCLUDE=TABLE:\"IN\(\'T1\'\)\"

  Export:>  Copyright (c) 2003, 2005, Oracle.  All rights reserved.

  Connected to: Oracle Database 10g Enterprise Edition>  With the Partitioning, Oracle Label Security, OLAP and Data Mining Scoring Engine options
  Starting "SEC"."SYS_EXPORT_SCHEMA_01":  sec/******** directory=dump_dir dumpfile=sec.dmp logfile=sec.log EXCLUDE=TABLE:"IN('T1')"
  Estimate in progress using BLOCKS method...
  Processing object type SCHEMA_EXPORT/TABLE/TABLE_DATA
  Total estimation using BLOCKS method: 128 KB
  Processing object type SCHEMA_EXPORT/USER
  Processing object type SCHEMA_EXPORT/SYSTEM_GRANT
  Processing object type SCHEMA_EXPORT/ROLE_GRANT
  Processing object type SCHEMA_EXPORT/DEFAULT_ROLE
  Processing object type SCHEMA_EXPORT/PRE_SCHEMA/PROCACT_SCHEMA
  Processing object type SCHEMA_EXPORT/TABLE/TABLE
  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/COMMENT
  . . exported "SEC"."T2"                                  4.914 KB       1 rows
  . . exported "SEC"."T3"                                  4.914 KB       1 rows
  Master table "SEC"."SYS_EXPORT_SCHEMA_01" successfully loaded/unloaded
  ******************************************************************************
  Dump file set for SEC.SYS_EXPORT_SCHEMA_01 is:
  /expdp/sec.dmp
  Job "SEC"."SYS_EXPORT_SCHEMA_01" successfully completed at 10:02:10
  排除表T1后T2和T3表被成功导出。
  7.排除多张表进行备份
  以排除表T1和T2两张表为例进行演示
  ora10g@secDB /expdp$ rm -f sec.dmp sec.log
  ora10g@secDB /expdp$ expdp sec/sec directory=dump_dir dumpfile=sec.dmp logfile=sec.log EXCLUDE=TABLE:\"IN\(\'T1\',\'T2\'\)\"

  Export:>  Copyright (c) 2003, 2005, Oracle.  All rights reserved.

  Connected to: Oracle Database 10g Enterprise Edition>  With the Partitioning, Oracle Label Security, OLAP and Data Mining Scoring Engine options
  Starting "SEC"."SYS_EXPORT_SCHEMA_01":  sec/******** directory=dump_dir dumpfile=sec.dmp logfile=sec.log EXCLUDE=TABLE:"IN('T1','T2')"
  Estimate in progress using BLOCKS method...
  Processing object type SCHEMA_EXPORT/TABLE/TABLE_DATA
  Total estimation using BLOCKS method: 64 KB
  Processing object type SCHEMA_EXPORT/USER
  Processing object type SCHEMA_EXPORT/SYSTEM_GRANT
  Processing object type SCHEMA_EXPORT/ROLE_GRANT
  Processing object type SCHEMA_EXPORT/DEFAULT_ROLE
  Processing object type SCHEMA_EXPORT/PRE_SCHEMA/PROCACT_SCHEMA
  Processing object type SCHEMA_EXPORT/TABLE/TABLE
  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/COMMENT
  . . exported "SEC"."T3"                                  4.914 KB       1 rows
  Master table "SEC"."SYS_EXPORT_SCHEMA_01" successfully loaded/unloaded
  ******************************************************************************
  Dump file set for SEC.SYS_EXPORT_SCHEMA_01 is:
  /expdp/sec.dmp
  Job "SEC"."SYS_EXPORT_SCHEMA_01" successfully completed at 10:03:24
  排除表T1和T2后T3表被成功导出。
  注意在Linux的bash下特殊字符的转义处理
  8.使用PARFILE参数规避不同操作系统中特殊字符的转义
  为了规避不同操作系统上特殊字符转义带来的麻烦,我们可以使用PARFILE参数规避一下这个难题。
  ora10g@secDB /expdp$ vi sec.par
  userid=sec/sec
  directory=dump_dir
  dumpfile=sec.dmp
  logfile=sec.log
  EXCLUDE=TABLE:"IN('T1','T2')"
  ~
  ~
  ora10g@secDB /expdp$ rm -f sec.dmp sec.log
  ora10g@secDB /expdp$ expdp parfile=sec.par

  Export:>  Copyright (c) 2003, 2005, Oracle.  All rights reserved.

  Connected to: Oracle Database 10g Enterprise Edition>  With the Partitioning, Oracle Label Security, OLAP and Data Mining Scoring Engine options
  Starting "SEC"."SYS_EXPORT_SCHEMA_01":  parfile=sec.par
  Estimate in progress using BLOCKS method...
  Processing object type SCHEMA_EXPORT/TABLE/TABLE_DATA
  Total estimation using BLOCKS method: 64 KB
  Processing object type SCHEMA_EXPORT/USER
  Processing object type SCHEMA_EXPORT/SYSTEM_GRANT
  Processing object type SCHEMA_EXPORT/ROLE_GRANT
  Processing object type SCHEMA_EXPORT/DEFAULT_ROLE
  Processing object type SCHEMA_EXPORT/PRE_SCHEMA/PROCACT_SCHEMA
  Processing object type SCHEMA_EXPORT/TABLE/TABLE
  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/COMMENT
  . . exported "SEC"."T3"                                  4.914 KB       1 rows
  Master table "SEC"."SYS_EXPORT_SCHEMA_01" successfully loaded/unloaded
  ******************************************************************************
  Dump file set for SEC.SYS_EXPORT_SCHEMA_01 is:
  /expdp/sec.dmp
  Job "SEC"."SYS_EXPORT_SCHEMA_01" successfully completed at 10:10:35
  在完成特殊条件导出时,推荐将需要的所有参数统一写到参数文件中。
  9.小结
  EXPDP工具与EXP相比不仅仅是效率上的提升,更重要的是功能上的增强。
  本文中以EXPDP的EXCLUDE选项为例展示了此工具的便捷之处,善用之。
  Good luck.
  secooler
  10.03.08
  -- The End --


运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.iyunv.com/thread-600208-1-1.html 上篇帖子: oracle数据库SQL题 下篇帖子: 去除Oracle 8080端口的占用。- -
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表