1. 程式人生 > >資料泵expdp中query的使用及注意事項

資料泵expdp中query的使用及注意事項

    在用資料泵匯出資料的時候,有時候我們需要按條件過濾掉一些不需要匯出的資料,這時候就需要用到引數query。下面是一個簡單使用query的小例子,在這個例子中我們也可以看出資料泵的一個缺陷,就是query引數和estimate引數是衝突的,當我們使用query引數的時候,資料泵estimate資料量會忽略query引數的過濾,使的estimate值異常。

expdp systemparfile=bi_20131203.par

Export: Release11.2.0.3.0 - Production on Tue Dec 3 18:51:04 2013

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

Password:

Connected to: OracleDatabase 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production

With thePartitioning, Real Application Clusters, Automatic Storage Management, OLAP,

Data Mining and RealApplication Testing options

Starting"SYSTEM"."SYS_EXPORT_TABLE_01":  system/******** parfile=bi_20131203.par

Estimate in progressusing BLOCKS method...

Processing objecttype TABLE_EXPORT/TABLE/TABLE_DATA

Total estimationusing BLOCKS method: 61.75 GB

Processing objecttype TABLE_EXPORT/TABLE/TABLE

Processing objecttype TABLE_EXPORT/TABLE/GRANT/OWNER_GRANT/OBJECT_GRANT

檢視下引數檔案more bi_20131203.par

directory=dump_bi

tables=bi_dw.DW_MID_CONTRACT

cluster=n filesize=4G

dumpfile=expdp_bi_ods_tables_20131203_%U.dmp 

query=bi_dw.DW_MID_CONTRACT:"where data_date in(to_date('2013-11-13','yyyy-mm-dd'),to_date('2013-11-14','yyyy-mm-dd'),to_date('2013-8-13','yyyy-mm-dd'),to_date('2013-8-14','yyyy-mm-dd'))"

nologfile=y

通過資料庫檢視到DW_MID_CONTRACT這張表有1.6億的資料量,該表的segment達到了60G然而過濾後的資料只有2639086 rows,然而expdp計算的值

Total estimationusing BLOCKS method: 61.75 GB

最終,我們匯出的檔案僅僅只有873M  expdp_bi_ods_tables_20131203_01.dmp

另外在資料泵導資料的過程中,我們可以expdp system ATTACH=SYS_EXPORT_TABLE_01到該任務。

job的名字可以通過job引數指定,也可以走預設,dba_datapump_jobs中記載了正在執行的資料泵任務。

select * from dba_datapump_jobs;

SYS_EXPORT_TABLE_01