Oracle數(shù)據(jù)泵實(shí)現(xiàn)不同用戶導(dǎo)入導(dǎo)出表級(jí)
前言:
先認(rèn)識(shí)一個(gè)單詞,schema:模式。
再來(lái)了解一個(gè)概念。
當(dāng)創(chuàng)建一個(gè)用戶的時(shí)候,會(huì)同時(shí)創(chuàng)建一個(gè)與用戶同名的schema,這個(gè)schema的官方解釋是對(duì)象的集合。
舉個(gè)例子,比如說(shuō)我就是一個(gè)用戶,叫A,住在某個(gè)公寓里,假如我住在4-404,那么這個(gè)4-404這個(gè)房間就是schema,房間名也叫A(意思是用戶A的房間,在oracle里的意思是用戶A的schema)。那么房間里面的東西就是對(duì)象了,比如說(shuō)桌子,冰箱,床之類的。所以說(shuō)schema是對(duì)象的集合。(個(gè)人理解,不對(duì)之處,請(qǐng)以斧正)
在使用數(shù)據(jù)泵前設(shè)定一個(gè)directory,就是存放數(shù)據(jù)泵文件的目錄。
create directory data_dump as "/data_dump";
當(dāng)然,也可以查看有哪些目錄
select directory_name,directory_path from dba_directories;
下面來(lái)記一些參數(shù):
- serid:說(shuō)明使用的是哪個(gè)用戶進(jìn)行操作
- directory:說(shuō)明使用的是哪個(gè)邏輯目錄(就是上面創(chuàng)建的那個(gè))
- dumpfile :導(dǎo)出后的文件名字
- logfile: 導(dǎo)出過(guò)程中的日志文件
- tables :導(dǎo)出的表
下面是導(dǎo)出腳本及expdp:
cat >exp_table.par<<EOF userid=" / as sysdba" directory=data_dump dumpfile=exp_table_%u.dmp logfile=exp_table.log tables=(scott.temp,scott.tjy_test) cluster=n parallel=4 exclude=STATISTICS compression=ALL EOF nohup expdp parfile=exp_table.par>exp_table.par.out & tail -100f exp_table.par.out
對(duì)上面參數(shù)進(jìn)行解釋說(shuō)明:
userid=' / as sydba':說(shuō)明用的是sys用戶執(zhí)行的數(shù)據(jù)泵操作
directory=data_dump:說(shuō)明操作路徑是data_dump(也就是上面創(chuàng)建的那個(gè)目錄)
dumpfile=exp_table_%u.dmp:這里僅僅是說(shuō)明導(dǎo)出后的文件命名,exp_表示這是導(dǎo)出的文件,table_表示表級(jí)操作,%u表示01-99的自動(dòng)增長(zhǎng)的整數(shù),.dmp表示文件后綴
logfile=exp_table.log:跟上面的解釋差不多。
tables=(scott.temp,scott.test):說(shuō)明要導(dǎo)出的是scott里的temp表和test表,注意這里的scott指的是schema,而不是username
其他的沒(méi)什么好說(shuō)的,想學(xué)自己百度。
下面是導(dǎo)入腳本及impdp:
cat >imp_table.par<<EOF userid=" / as sysdba" directory=DATA_DUMP dumpfile=exp_table_%u.dmp logfile=imp_table.log TABLE_EXISTS_ACTION=append tables=(scott.temp,scott.test) remap_schema=scott:sys cluster=n parallel=8 EOF nohup impdp parfile=imp_table.par>imp_table.par.out & tail -100f imp_table.par.out
這個(gè)跟上面的其實(shí)沒(méi)多大改變,目錄還是那個(gè)目錄。
需要注意的是多了一行table_exists_action=append 這行表示在原有表的基礎(chǔ)上添加要導(dǎo)入的數(shù)據(jù)。
還有一行是remap_schema=scott:sys重點(diǎn)是這里,因?yàn)閟cott.temp的scott指的是schema,所以參數(shù)是remap_schema。 scott:sys的意思是在這些個(gè)數(shù)據(jù)泵文件里,schema是scott的,換成sys。
到此這篇關(guān)于Oracle數(shù)據(jù)泵實(shí)現(xiàn)不同用戶導(dǎo)入導(dǎo)出表級(jí)的文章就介紹到這了,更多相關(guān)Oracle數(shù)據(jù)泵導(dǎo)入導(dǎo)出內(nèi)容請(qǐng)搜索以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持!
