oracle Imdpd覆盖,zzw原創_expdp及impdp中的exclude及include參數的那點事

zzw原創:轉載請注明出處

在oracle的expdp 及imdpd命令中,exclude及include參數還是有一些要注意的地方,特別是涉及選擇性條件時。

一、通用

1、exclude及include參數不能同時使用,這兩個是相互排斥的。

2、在parfile參數文件中,可以同時用多個exclude參數,但只能用一個include參數

3、include、exclude參數是默認就是針對對象名稱操作的:如表名、視圖名、過程名、包名等,所以設計條件時,可以從查詢語句select  distinct(object_type)  from  all_objects中先取得這些名稱。

4、include、exclude參數中,在escape語句中,不能用\作為轉義符

(1)、include=table:"like 'SEC_%'"

結果:SECAAAROLE、SEC_ROLE、SEC_OPERATION三個表,說明,_依舊表示一個占位符的作用

(2)、include=table:"like 'SEC\_%'"

不能導出SECAAAROLE、SEC_ROLE、SEC_OPERATION三個表,說明在''中,\並不表示轉義符

(3)、include=table:"like 'SEC\_%'escape'\'"  這樣會報錯:

ORA-39001: invalid argument value

ORA-39071: Value for INCLUDE is badly formed.

ORA-01425: escape character must be character string of length 1

(4)、改成這樣  include=table:"like 'SEC#_%'escape'#'"

可以正確導出SEC_ROLE、SEC_OPERATION二個表,但不能導出SECAAAROLE這個表。結論:在include、exclude參數中,在escape語句中,不能用\作為轉義符!!,可以選用選用其他特殊字符作為轉義符。如果確實要用\,也要可以用ascii碼代替:include=table:"like 'SEC\_%'escape chr(92)"

二、exclude參數用法

a、exclude參數在parfile文件中可以有多個,還有多種寫法。

[oracle@test189 temp2]$ vi zzw-expscript_impclude.par

DIRECTORY=ZZW_EXPDPDIR

DUMPFILE=bdctemp1.dmp

exclude=table:"like 'BDC%'" , table:"like 'USPC%'",table:"like 'AUDIT%'"

exclude=table:"like 'SMS#_%'escape'#'"

exclude=table:"in (select table_name from user_tables  where regexp_like(table_name,'^MENU.*')

or regexp_like(table_name,'^SEC_.*_.*$'))"

LOGFILE=bdctemp1.log

b、支持換行,比如,上面的語句,在parfile文件中如下換行也是可以的

[oracle@test189 temp2]$ vi zzw-expscript_impclude.par

DIRECTORY=ZZW_EXPDPDIR

DUMPFILE=bdctemp1.dmp

EXCLUDE=STATISTICS

exclude=view,table:"like 'BDC%'" ,

table:"like 'USPC%'",

table:"like 'AUDIT%'"

exclude=table:"like 'SMS#_%'escape'#'"

exclude=table:"in (select table_name from user_tables  where regexp_like(table_name,'^MENU.*')

or regexp_like(table_name,'^SEC_.*_.*$'))"

LOGFILE=bdctemp1.log

ps:采用這種exclude=table:"in (select table_name from user_tables)"方法導出時,我環境中會出現 ORA-07445: exception encountered: core dump     [kokemisz()+34] [SIGSEGV] [ADDR:0x18] [PC:0x143F5B6] [Address not mapped to object] []  這樣的錯誤,在parfile文件中加入 EXCLUDE=STATISTICS條件問題就解決了。

三、include參數用法

a、不允許的寫法

include=table:"='BOSS'" or table:"='SEC_ROLE'"

include=table:"='BOSS'" , table:"='SEC_ROLE'"

b、允許的寫法

include=table:"='BOSS'"

include=table:"in('BOSS','SEC_ROLE')"

include=table:"in(select table_name from user_tables  where table_name in('BOSS','SEC_ROLE'))"

include=table:"in(select table_name from user_tables  where regexp_like(table_name,'^BDC_.{4}_.*$'))"   #注意,_在like中表示占位符,在regexp_like不表示占位符。

include=table:"in(select table_name from user_tables  where regexp_like(table_name,'^BDC_.{8}_.*$') or regexp_like(table_name,'^ATTACHMENT_.{4}') or  table_name like 'QRTZ#_%'escape'#')"

導出某些無規律的表,有很多,也許需要動態維護

建立表exp_table

create table exp_table (table_name varchar2(100);

然后將需要導出的表名插入exp_table中。

insert into exp_table values(‘A’);

insert into exp_table values(‘B’);

insert into exp_table values(‘PUB_GOODS’);

insert into exp_table values(‘PUB_GOODS_UNIT’);

最后導出的的時候:

parfile

userid=user/passwd

directory=expdir

dumpfile=testfile.dmp

include=table:" in (select table_name from exp_table ) "

這樣就可以導出exp_table中所包含的所有表了。更神奇的是,可以在exp_table里面將自己也插入進去,然后把exp_table也導出哦

d、這樣的寫法是錯誤的,因為包含兩個include語句

DIRECTORY=ZZW_EXPDPDIR

DUMPFILE=bdctemp1.dmp

include=table:"='BOSS'"

include=table:"='SIMS'"

by zzw 2017.3.28

by zzw 2017.4.13修改 於aspire

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值