【EXP】使用EXP的QUERY選項匯出表中部分資料

secooler發表於2010-03-07
簡單演示一下使用EXP的QUERY選項匯出表中部分資料(具有where限制條件的匯出)。

1.建立實驗表T,並初始化4條記錄
sec@secooler> create table t (x int ,y varchar2(20));

Table created.

sec@secooler> insert into t values (1,'sec1');

1 row created.

sec@secooler> insert into t values (2,'sec2');

1 row created.

sec@secooler>
sec@secooler> insert into t values (3,'sec3');

1 row created.

sec@secooler> insert into t values (4,'sec4');

1 row created.

sec@secooler> commit;

Commit complete.

sec@secooler> select * from t;

         X Y
---------- ------------------------------------------------------------
         1 sec1
         2 sec2
         3 sec3
         4 sec4

2.按照“x<3”條件匯出T表中的部分資料
secooler@secDB /exp$ exp sec/sec file=sec.dmp log=sec.log tables=t query=\"where x\<3\"

Export: Release 11.2.0.1.0 - Production on Sun Mar 7 20:19:43 2010

Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.


Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, Oracle Label Security, OLAP, Data Mining,
Oracle Database Vault and Real Application Testing option
Export done in AL32UTF8 character set and AL16UTF16 NCHAR character set
server uses ZHS16GBK character set (possible charset conversion)

About to export specified tables via Conventional Path ...
. . exporting table                              T          2 rows exported
Export terminated successfully without warnings.

OK,匯出成功,滿足“x<3”條件的T表資料有兩條。

3.小結
EXP工具的每一個選項都有其重要的應用場合。
當僅需要備份表中部分資料時,您也不妨使用一下QUERY選項,注意這個選項要與TABLES選項一同使用,同時注意在命令列中特殊字元的轉義方法。

Good luck.

secooler
10.03.07

-- The End --

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/519536/viewspace-628841/,如需轉載,請註明出處,否則將追究法律責任。

相關文章