ITPub博客

首页 > Linux操作系统 > Linux操作系统 > 【EXPDP】使用expdp的QUERY参数限定备份数据的范围

【EXPDP】使用expdp的QUERY参数限定备份数据的范围

原创 Linux操作系统 作者:secooler 时间:2009-03-02 16:14:45 0 删除 编辑
1.创建试验表test_table
ora11g@RHEL53 /home/oracle$ sqlplus sec/sec

SQL*Plus: Release 11.1.0.6.0 - Production on Mon Mar 2 18:28:50 2009

Copyright (c) 1982, 2007, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

sec@ora11g> select * from cat;

no rows selected

sec@ora11g> create table test_table as select * from dba_objects where rownum<1000;

Table created.

sec@ora11g> select count(*) from test_table;

  COUNT(*)
----------
       999

2.使用参数文件进行导出
ora11g@RHEL53 /home/oracle$ cat test_tables_query.par
QUERY=test_table:"where rownum<10"
NOLOGFILE=y
DIRECTORY=DATA_PUMP_DIR
DUMPFILE=expdp_test_table.dmp

ora11g@RHEL53 /home/oracle$ expdp sec/sec parfile=test_tables_query.par reuse_dumpfiles=y

Export: Release 11.1.0.6.0 - Production on Monday, 02 March, 2009 18:35:10

Copyright (c) 2003, 2007, Oracle.  All rights reserved.

Connected to: Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Starting "SEC"."SYS_EXPORT_SCHEMA_01":  sec/******** parfile=test_tables_query.par reuse_dumpfiles=y
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"."TEST_TABLE"                          11.42 KB       9 rows
Master table "SEC"."SYS_EXPORT_SCHEMA_01" successfully loaded/unloaded
******************************************************************************
Dump file set for SEC.SYS_EXPORT_SCHEMA_01 is:
  /oracle/u01/app/oracle/admin/ora11g/dpdump/expdp_test_table.dmp
Job "SEC"."SYS_EXPORT_SCHEMA_01" successfully completed at 18:35:38


3.单条语句导出时,需要加一对单引号QUERY=test_table:'"where rownum<10"'
ora11g@RHEL53 /home/oracle$ expdp sec/sec reuse_dumpfiles=y QUERY=test_table:'"where rownum<10"' NOLOGFILE=y DIRECTORY=DATA_PUMP_DIR DUMPFILE=expdp_test_table.dmp

ora11g@RHEL53 /home/oracle$ expdp sec/sec reuse_dumpfiles=y QUERY='test_table:"where rownum<10"' NOLOGFILE=y DIRECTORY=DATA_PUMP_DIR DUMPFILE=expdp_test_table.dmp

Export: Release 11.1.0.6.0 - Production on Monday, 02 March, 2009 18:38:21

Copyright (c) 2003, 2007, Oracle.  All rights reserved.

Connected to: Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Starting "SEC"."SYS_EXPORT_SCHEMA_01":  sec/******** reuse_dumpfiles=y QUERY=test_table:"where rownum<10" NOLOGFILE=y DIRECTORY=DATA_PUMP_DIR DUMPFILE=expdp_test_table.dmp
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"."TEST_TABLE"                          11.42 KB       9 rows
Master table "SEC"."SYS_EXPORT_SCHEMA_01" successfully loaded/unloaded
******************************************************************************
Dump file set for SEC.SYS_EXPORT_SCHEMA_01 is:
  /oracle/u01/app/oracle/admin/ora11g/dpdump/expdp_test_table.dmp
Job "SEC"."SYS_EXPORT_SCHEMA_01" successfully completed at 18:38:40


secooler
09.03.02

-- The End --

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/519536/viewspace-558297/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论
Oracle ACE 总监,阿里云MVP,北京大学理学硕士,恩墨学院创始人,教育专家,中国区 Cloudera 首位官方授权大数据讲师,金牌培训专家,BDA大数据联盟创始人,OCM联盟创始人,ACCUG创始人、ACOUG核心专家,Blogger。

注册时间:2008-03-16

  • 博文量
    797
  • 访问量
    8059281