【EXPDP】使用expdp的QUERY引數限定備份資料的範圍

secooler發表於2009-03-02
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/,如需轉載,請註明出處,否則將追究法律責任。

相關文章