天天看点

【oracle 导入、导出】escape 的作用。

sql> conn yang/yang as sysdba

已连接。

sql> select table_name from dba_tables where table_name like 't_%';---在这里 _ 被当作通配符来处理。

table_name                                                                     

------------------------------                                                 

tab$                                                                           

type_misc$                                                                     

ts$                                                                            

tsq$                                                                           

typed_view$                                                                    

trusted_list$                                                                  

trigger$                                                                       

triggercol$                                                                    

triggerjavaf$                                                                  

triggerjavas$                                                                  

triggerjavac$                                                                  

triggerjavam$                                                                  

triggerdep$                                                                    

tsm_src$                                                                       

tsm_dst$                                                                       

table_privilege_map                                                            

tab_stats$                                                                     

type$                                                                          

typehierarchy$                                                                 

tabpart$                                                                       

tabsubpart$                                                                    

tabcompart$                                                                    

transaction_backout_state$                                                     

transaction_backout_report$                                                    

transformations$                                                               

tokensessionmap_t$                                                             

t1                                                                             

t2                                                                             

tts_tbs$                                                                       

tts_usr$                                                                       

tts_error$                                                                     

已选择31行。

sql> select table_name from dba_tables where table_name like 'tts\_%' escape '\';--加上escape后,_ 当作下划线来处理

tts_tbs$

当需要导出某一类表比如以 test_ 开头的表时 escape 就派上用场了,导出test_1 test_2 这两个表。

sql> conn scott/tiger

connected.

sql> select * from tab;

tname                          tabtype  clusterid

------------------------------ ------- ----------

dept                           table

emp                            table

bonus                          table

salgrade                       table

test_1                         table

test_2                         table

testa                          table

testb                          table

sql> select tname from tab where tname like 'test\_%' escape '\';

tname

------------------------------

test_1

test_2

sql> conn / as sysdba

sql> create or replace directory dumpdir as  'd:\dump';

sql> grant read,write on directory dumpdir to scott;

c:\documents and settings\administrator>expdp scott/tiger directory=dumpdir dumpfile=expdp_scott_test.dmp logfile=expdp_scott_test.log schemas=scott include=table:\"in \( select tname from tab where tname like 'testq_%' escape 'q' \)\"

export: release 10.1.0.2.0 - production on 星期五, 22 10月, 2010 12:45

copyright (c) 2003, oracle.  all rights reserved.

connected to: oracle database 10g enterprise edition release 10.1.0.2.0 - production

with the partitioning, olap and data mining options

flashback automatically enabled to preserve database integrity.

starting "scott"."sys_export_schema_01":  scott/******** directory=dumpdir dumpfile=exp_tab.dmp logfile=exp_tab.log schemas=scott include=table:"in \( select tn

ame from tab where tname like 'testq_%' escape 'q' \)"

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/table/table

. . exported "scott"."test_1"                            7.820 kb      14 rows

. . exported "scott"."test_2"                            7.820 kb      14 rows

master table "scott"."sys_export_schema_01" successfully loaded/unloaded

******************************************************************************

dump file set for scott.sys_export_schema_01 is:

  d:\dump\exp_tab.dmp

job "scott"."sys_export_schema_01" successfully completed at 12:45

---导出部分的实例来自与puber  stanley !