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

  1. 云栖社区>
  2. 博客列表>
  3. 正文

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

北在南方 2016-04-15 14:12:56 浏览444 评论0

摘要: SQL> conn yang/yang as sysdba 已连接。 SQL> select table_name from dba_tables where table_name like 'T_%';---在这里 _ 被当作通配符来处理。

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$                                                                  

TABLE_NAME                                                                     
------------------------------                                                 
TRIGGERJAVAM$                                                                  
TRIGGERDEP$                                                                    
TSM_SRC$                                                                       
TSM_DST$                                                                       
TABLE_PRIVILEGE_MAP                                                            
TAB_STATS$                                                                     
TYPE$                                                                          
TYPEHIERARCHY$                                                                 
TABPART$                                                                       
TABSUBPART$                                                                    
TABCOMPART$                                                                    

TABLE_NAME                                                                     
------------------------------                                                 
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后,_ 当作下划线来处理
TABLE_NAME                                                                     
------------------------------                                                 
TTS_ERROR$                                                                     
TTS_USR$                                                                       
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 !

用云栖社区APP,舒服~

【云栖快讯】诚邀你用自己的技术能力来用心回答每一个问题,通过回答传承技术知识、经验、心得,问答专家期待你加入!  详情请点击

网友评论

北在南方
文章661篇 | 关注25
关注
云数据库PPAS版,是阿里云与EnterpriseDB公司合作基于PostgreSQL高度兼... 查看详情
快速、完全托管的TB/PB级数据仓库解决方案,向用户提供了完善的数据导入方案以及多种经典的分... 查看详情
RDS是一种稳定可靠、可弹性伸缩的在线数据库服务。支持MySQL、SQL Server、Po... 查看详情
为您提供简单高效、处理能力可弹性伸缩的计算服务,帮助您快速构建更稳定、安全的应用,提升运维效... 查看详情
阿里云总监课正式启航

阿里云总监课正式启航