expdp中提供了query參數(shù),可以在需要按條件導(dǎo)出表中部分?jǐn)?shù)據(jù)時(shí)使用,它的使用就像是在select語句中的where條件使用一樣。
創(chuàng)新互聯(lián)建站于2013年開始,是專業(yè)互聯(lián)網(wǎng)技術(shù)服務(wù)公司,擁有項(xiàng)目網(wǎng)站設(shè)計(jì)、成都網(wǎng)站設(shè)計(jì)網(wǎng)站策劃,項(xiàng)目實(shí)施與項(xiàng)目整合能力。我們以讓每一個(gè)夢想脫穎而出為使命,1280元澄城做網(wǎng)站,已為上家服務(wù),為澄城各地企業(yè)和個(gè)人服務(wù),聯(lián)系電話:13518219792數(shù)據(jù)庫版本
zx@ORCL>select * from v$version; BANNER -------------------------------------------------------------------------------- Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production PL/SQL Release 11.2.0.4.0 - Production CORE11.2.0.4.0Production TNS for Linux: Version 11.2.0.4.0 - Production NLSRTL Version 11.2.0.4.0 - Production創(chuàng)建測試表
zx@ORCL>create table e1 (id number,name varchar2(20)); Table created. zx@ORCL>create table e2 (id number,birthday date); Table created.插入測試數(shù)據(jù)
zx@ORCL>insert into e1 select level,lpad(level,20,'*') from dual connect by level <= 100; 100 rows created. zx@ORCL>commit; Commit complete. zx@ORCL>insert into e2 select level,sysdate-50+level from dual connect by level <= 100; 100 rows created. zx@ORCL>commit; Commit complete.創(chuàng)建目錄
zx@ORCL>create directory dir as '/home/oracle/'; Directory created. zx@ORCL>host測試使用query導(dǎo)出
注意:如果query條件在parfile中則不需要用'\'進(jìn)行轉(zhuǎn)義
[oracle@rhel6 ~]$ expdp zx/zx directory=dir dumpfile=e1.dmp tables=zx.e1 query=zx.e1:\"where id<=50\" bash: =50": No such file or directory Export: Release 11.2.0.4.0 - Production on Thu Jul 21 14:23:11 2016 Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved. Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options Starting "ZX"."SYS_EXPORT_TABLE_01": zx/******** directory=dir dumpfile=e1.dmp tables=zx.e1 query=zx.e1:"where id<=50" Estimate in progress using BLOCKS method... Processing object type TABLE_EXPORT/TABLE/TABLE_DATA Total estimation using BLOCKS method: 64 KB Processing object type TABLE_EXPORT/TABLE/TABLE . . exported "ZX"."E1" 6.757 KB 50 rows Master table "ZX"."SYS_EXPORT_TABLE_01" successfully loaded/unloaded ****************************************************************************** Dump file set for ZX.SYS_EXPORT_TABLE_01 is: /home/oracle/e1.dmp Job "ZX"."SYS_EXPORT_TABLE_01" successfully completed at Thu Jul 21 14:23:26 2016 elapsed 0 00:00:11 exit查詢scn號
zx@ORCL>select dbms_flashback.get_system_change_number from dual; GET_SYSTEM_CHANGE_NUMBER ------------------------ 2179047 zx@ORCL>select count(*) from e1; COUNT(*) ---------- 100刪除部分?jǐn)?shù)據(jù)
zx@ORCL>delete from e1 where id<20; 19 rows deleted. zx@ORCL>commit; Commit complete. zx@ORCL>host測試query及flashback_scn
[oracle@rhel6 ~]$ expdp zx/zx directory=dir dumpfile=e1_1.dmp tables=zx.e1 query=zx.e1:\"where id\<=50\" flashback_scn=2179047 Export: Release 11.2.0.4.0 - Production on Thu Jul 21 14:25:41 2016 Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved. Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options Starting "ZX"."SYS_EXPORT_TABLE_01": zx/******** directory=dir dumpfile=e1_1.dmp tables=zx.e1 query=zx.e1:"where id<=50" flashback_scn=2179047 Estimate in progress using BLOCKS method... Processing object type TABLE_EXPORT/TABLE/TABLE_DATA Total estimation using BLOCKS method: 64 KB Processing object type TABLE_EXPORT/TABLE/TABLE . . exported "ZX"."E1" 6.757 KB 50 rows Master table "ZX"."SYS_EXPORT_TABLE_01" successfully loaded/unloaded ****************************************************************************** Dump file set for ZX.SYS_EXPORT_TABLE_01 is: /home/oracle/e1_1.dmp Job "ZX"."SYS_EXPORT_TABLE_01" successfully completed at Thu Jul 21 14:25:49 2016 elapsed 0 00:00:06 [oracle@rhel6 ~]$ exit exit測試復(fù)雜query導(dǎo)出
zx@ORCL>select count(*) from e1 where id in( select id from e2 where birthday測試復(fù)雜query及flashback_scn導(dǎo)出
[oracle@rhel6 ~]$ expdp zx/zx directory=dir dumpfile=e1_3.dmp tables=zx.e1 query=zx.e1:\"where id in \( select id from e2 where birthday\刪除e2部分?jǐn)?shù)據(jù)
zx@ORCL>delete from e2 where id>25 and id<30; 4 rows deleted. zx@ORCL>commit; Commit complete. zx@ORCL>select count(*) from e1 where id in( select id from e2 where birthday測試query及flashback_scn,結(jié)果只是對e1應(yīng)用flashback_snc,e2沒有應(yīng)用
zx@ORCL>host [oracle@rhel6 ~]$ expdp zx/zx directory=dir dumpfile=e1_4.dmp tables=zx.e1 query=zx.e1:\"where id in \( select id from e2 where birthday\使e1和e2都應(yīng)用flashback_scn
zx@ORCL>select count(*) from e1 where id in( select id from e2 as of scn 2179047 where birthday多個(gè)表使用query條件則使用','分開
[oracle@rhel6 ~]$ expdp system/123456 directory=dump dumpfile=query.dmp tables=zx.abc,zx.abce query=zx.abc:\"where id \< 4\",zx.abce:\"where id \< 4\" Export: Release 11.2.0.4.0 - Production on Fri Dec 9 16:13:41 2016 Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved. Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options FLASHBACK automatically enabled to preserve database integrity. Starting "SYSTEM"."SYS_EXPORT_TABLE_01": system/******** directory=dump dumpfile=query.dmp tables=zx.abc,zx.abce query=zx.abc:"where id < 4",zx.abce:"where id < 4" Estimate in progress using BLOCKS method... Processing object type TABLE_EXPORT/TABLE/TABLE_DATA Total estimation using BLOCKS method: 384 KB Processing object type TABLE_EXPORT/TABLE/TABLE . . exported "ZX"."ABC" 5.898 KB 2 rows . . exported "ZX"."ABCE" 5.898 KB 2 rows Master table "SYSTEM"."SYS_EXPORT_TABLE_01" successfully loaded/unloaded ****************************************************************************** Dump file set for SYSTEM.SYS_EXPORT_TABLE_01 is: /home/oracle/query.dmp Job "SYSTEM"."SYS_EXPORT_TABLE_01" successfully completed at Fri Dec 9 16:14:04 2016 elapsed 0 00:00:19另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)cdcxhl.cn,海內(nèi)外云服務(wù)器15元起步,三天無理由+7*72小時(shí)售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡單易用、服務(wù)可用性高、性價(jià)比高”等特點(diǎn)與優(yōu)勢,專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場景需求。