先認識一個單詞,schema:模式,
再來了解一個概念,
當創建一個用戶的時候,會同時創建一個與用戶同名的schema,這個schema的官方解釋是物件的集合,
舉個例子,比如說我就是一個用戶,叫A,住在某個公寓里,假如我住在4-404,那么這個4-404這個房間就是schema,房間名也叫A(意思是用戶A的房間,在oracle里的意思是用戶A的schema),那么房間里面的東西就是物件了,比如說桌子,冰箱,床之類的,所以說schema是物件的集合,(個人理解,不對之處,請以斧正)
在使用資料泵前設定一個directory,就是存放資料泵檔案的目錄,
create directory data_dump as '/data_dump';
當然,也可以查看有哪些目錄
select directory_name,directory_path from dba_directories;
下面來記一些引數
userid 說明使用的是哪個用戶進行操作
directory 說明使用的是哪個邏輯目錄(就是上面創建的那個)
dumpfile 匯出后的檔案名字
logfile 匯出程序中的日志檔案
tables 匯出的表
下面是匯出腳本及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
對上面引數進行解釋說明:
userid=' / as sydba' 說明用的是sys用戶執行的資料泵操作
directory=data_dump 說明操作路徑是data_dump(也就是上面創建的那個目錄)
dumpfile=exp_table_%u.dmp 這里僅僅是說明匯出后的檔案命名,exp_表示這是匯出的檔案,table_表示表級操作,%u表示01-99的自動增長的整數,.dmp表示檔案后綴
logfile=exp_table.log 跟上面的解釋差不多,
tables=(scott.temp,scott.test) 說明要匯出的是scott里的temp表和test表,注意這里的scott指的是schema,而不是username
其他的沒什么好說的,想學自己百度,
下面是匯入腳本及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
這個跟上面的其實沒多大改變,目錄還是那個目錄,
需要注意的是多了一行table_exists_action=append 這行表示在原有表的基礎上添加要匯入的資料,
還有一行是remap_schema=scott:sys 重點是這里,因為scott.temp的scott指的是schema,所以引數是remap_schema, scott:sys的意思是在這些個資料泵檔案里,schema是scott的,換成sys,
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/499679.html
標籤:Oracle
上一篇:Redis學習
下一篇:重新學習資料庫(1)
