在用數據泵導出數據的時候,有時候我們需要按條件過濾掉一些不需要導出的數據,這時候就需要用到參數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