資料泵基礎(impdp/expdp)
支援資料庫版本:10gR2
- 注意事項
expdp可以在客戶端或伺服器端執行,但檔案最終儲存在伺服器端
exp命令在哪裡執行,就匯出到哪裡
dbms_datapump --- pl/sql中呼叫
- 前期準備
建立轉存目錄
create directory backup_dir as 'c:\backup_dir'
賦予使用者訪問許可權
grant read,write on directory backup_dir to scott
查詢建立了哪些目錄
select * from dba_directories
匯入匯出命令
- 如果採用sysdba使用者
expdp 'sys/admin as sysdba'
- 表 --- tables=go.emp,scott.dept
匯出匯入指定表,表相關物件(索引,約束等,這些物件需要於表在相同表空間或匯出使用者具有匯出許可權)
向其他使用者匯入需要imp_full_database許可權
表可以指定 *
tables=scott.emp:p1 --- 表分割槽
tables=scott.e%
- 案(預設模式) --- schemas=scott,hr
有exp_full_database許可權則可以到處其他schema的表
預設不會匯出在本schema的物件的在其他schema中的關聯物件(如emp表的index在其他schema中時)
除非那個schema也在列表中出現,匯入也同樣
- 匯出表空間 --- tablespaces=users01,users02
到處指定表空間中,屬於本使用者的物件
匯出指定表空間中所有物件,需要exp_full_database許可權
- 匯出資料庫 --- full=y
需要exp_full_database許可權
grant exp_full_database to go
- 傳輸表空間 --- transport_tablespaces
需要exp/imp_full_database
匯出的是原資料,需要複製dmp和資料檔案到目標庫
- 過濾物件或資料
過濾資料
如果沒有指定表名則針對所有被匯出的表
建議放在parfile中
query=emp:"where id>5",dept:"where id<2"
sample=emp:50,dept:10 --- 匯出資料的百分比
過濾物件
指定任何物件型別和物件名字(支援*)
建議放在parfile中
include,exclude不能同時出現
exclude=index:"like 'IDX_EMP%'",constraint:"like 'CHK_EMP%'",grant
---------------------------------------------------------------------------------
多種情況對應
- 指定過濾條件 --- tables,include,exclude,query
注意tables和include條件中的大小寫,和跳脫字元
expdp go/go tables=\(go.e%\) directory=dump_file_dir query=\"where mgr=7698\" dumpfile=emp.dmp;
expdp go/go include=table:\"like \'E%\'\" directory=dump_file_dir query=emp:\"where mgr=7698\" dumpfile=expdp.dmp;
- 跨資料庫鏈方式匯出 --- network_link
間接實現匯出遠端資料庫物件到本地 ???
- 並行方式(不支援標準版) --- parallel + filesize
小資料量不一定能提高效率,設定不合理可能會影響效率
expdp go/go directory=dump_file_dir dumpfile=expdp.dmp parallel=2 filesize=30m;
- 僅匯入物件定義 --- content=all,data_only,metadata_only
- 匯入時清楚物件儲存的原資料 --- table_exists_action=skip,append,truncate,replace
- 匯入時重定義schema和表空間
remap_schema=scott:go,go:scott --- 同一impdp不能指定scott:go,scott:hr
remap_tablespace=users01:users02,users03:users04
- 退出輸出模式,進入互動管理模式 --- CTL+C
- 連線到輸出模式 --- expdp go/go attach=job_name
不指定attach則自動連線到當前任務
-- 執行管理操作
Export> add_file=exp_1_%U.dmp,exp_2_%U.dmp --- 新增輸出檔案,僅用於expdp
Export> continue_client --- 回到輸出模式
Export> exit_client --- 退出,回到OS命令列,expdp轉為後臺執行
Export> filesize=1G --- 指定最大檔案大小(G,M,K,B)
Export> help --- 顯示幫助
- 引數檔案
建立expdp.par
userid=go/go
schemas=scott,hr
dumpfile=scott%U.dmp
directory=backup_dir
logfile=scott.log
job_name=export_job
執行匯出
expdp go/go parfile=c:\backup\expdp.par
- 注意事項
expdp可以在客戶端或伺服器端執行,但檔案最終儲存在伺服器端
exp命令在哪裡執行,就匯出到哪裡
dbms_datapump --- pl/sql中呼叫
- 前期準備
建立轉存目錄
create directory backup_dir as 'c:\backup_dir'
賦予使用者訪問許可權
grant read,write on directory backup_dir to scott
查詢建立了哪些目錄
select * from dba_directories
匯入匯出命令
- 如果採用sysdba使用者
expdp 'sys/admin as sysdba'
- 表 --- tables=go.emp,scott.dept
匯出匯入指定表,表相關物件(索引,約束等,這些物件需要於表在相同表空間或匯出使用者具有匯出許可權)
向其他使用者匯入需要imp_full_database許可權
表可以指定 *
tables=scott.emp:p1 --- 表分割槽
tables=scott.e%
- 案(預設模式) --- schemas=scott,hr
有exp_full_database許可權則可以到處其他schema的表
預設不會匯出在本schema的物件的在其他schema中的關聯物件(如emp表的index在其他schema中時)
除非那個schema也在列表中出現,匯入也同樣
- 匯出表空間 --- tablespaces=users01,users02
到處指定表空間中,屬於本使用者的物件
匯出指定表空間中所有物件,需要exp_full_database許可權
- 匯出資料庫 --- full=y
需要exp_full_database許可權
grant exp_full_database to go
- 傳輸表空間 --- transport_tablespaces
需要exp/imp_full_database
匯出的是原資料,需要複製dmp和資料檔案到目標庫
- 過濾物件或資料
過濾資料
如果沒有指定表名則針對所有被匯出的表
建議放在parfile中
query=emp:"where id>5",dept:"where id<2"
sample=emp:50,dept:10 --- 匯出資料的百分比
過濾物件
指定任何物件型別和物件名字(支援*)
建議放在parfile中
include,exclude不能同時出現
exclude=index:"like 'IDX_EMP%'",constraint:"like 'CHK_EMP%'",grant
---------------------------------------------------------------------------------
多種情況對應
- 指定過濾條件 --- tables,include,exclude,query
注意tables和include條件中的大小寫,和跳脫字元
expdp go/go tables=\(go.e%\) directory=dump_file_dir query=\"where mgr=7698\" dumpfile=emp.dmp;
expdp go/go include=table:\"like \'E%\'\" directory=dump_file_dir query=emp:\"where mgr=7698\" dumpfile=expdp.dmp;
- 跨資料庫鏈方式匯出 --- network_link
間接實現匯出遠端資料庫物件到本地 ???
- 並行方式(不支援標準版) --- parallel + filesize
小資料量不一定能提高效率,設定不合理可能會影響效率
expdp go/go directory=dump_file_dir dumpfile=expdp.dmp parallel=2 filesize=30m;
- 僅匯入物件定義 --- content=all,data_only,metadata_only
- 匯入時清楚物件儲存的原資料 --- table_exists_action=skip,append,truncate,replace
- 匯入時重定義schema和表空間
remap_schema=scott:go,go:scott --- 同一impdp不能指定scott:go,scott:hr
remap_tablespace=users01:users02,users03:users04
- 退出輸出模式,進入互動管理模式 --- CTL+C
- 連線到輸出模式 --- expdp go/go attach=job_name
不指定attach則自動連線到當前任務
-- 執行管理操作
Export> add_file=exp_1_%U.dmp,exp_2_%U.dmp --- 新增輸出檔案,僅用於expdp
Export> continue_client --- 回到輸出模式
Export> exit_client --- 退出,回到OS命令列,expdp轉為後臺執行
Export> filesize=1G --- 指定最大檔案大小(G,M,K,B)
Export> help --- 顯示幫助
- 引數檔案
建立expdp.par
userid=go/go
schemas=scott,hr
dumpfile=scott%U.dmp
directory=backup_dir
logfile=scott.log
job_name=export_job
執行匯出
expdp go/go parfile=c:\backup\expdp.par
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/22558114/viewspace-1097762/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- expdp impdp Data Pump(資料泵)使用解析
- EXPDP 和 IMPDP 資料泵的使用_1
- EXPDP 和 IMPDP 資料泵的使用_2
- Oracle資料泵匯出匯入(expdp/impdp)Oracle
- 按計劃瞭解資料泵expdp/impdp
- 使用資料泵(expdp、impdp)遷移資料庫流程資料庫
- Oracle使用資料泵 (expdp/impdp)實施遷移Oracle
- 資料庫泵(expdp/impdp)匯入匯出流程資料庫
- 10g 資料泵(Data Dump) -- EXPDP & IMPDP [zt]
- 使用impdp,expdp資料泵進入海量資料遷移
- Oracle使用資料泵expdp,impdp進行資料匯出匯入Oracle
- 資料泵datapump(expdp/impdp)的parfile用法,避免跳脫字元字元
- 【Datapump】Oracle資料泵遷移資料命令參考(expdp/impdp說明)Oracle
- 資料泵 impdp 操作
- 資料泵(expdp,impdp)高版本匯入低版本操作例項
- Impdp資料泵匯入
- 10G資料泵載入命令expdp/impdp的引數說明
- 【impdp】IMPDP中的TRANSFORM引數--【資料泵】EXPDP匯出表結構(真實案例)後傳ORM
- 使用資料泵impdp匯入資料
- oracle資料庫的impdp,expdpOracle資料庫
- EXPDP資料泵使用方法
- Linux下執行資料泵expdp和impdp命令,字元轉義案例兩則Linux字元
- Oracle12c中資料泵新特性之功能增強(expdp, impdp)Oracle
- oracle資料泵備份(Expdp命令)Oracle
- 使用expdp、impdp遷移資料庫資料庫
- 使用資料泵工具expdp工具匯出資料
- 資料泵IMPDP 匯入工具的使用
- Oracle expdp資料泵遠端匯出Oracle
- 資料泵 EXPDP 匯出工具的使用
- oracle10g expdp資料泵的bug,按schema匯出,匯入impdp時無jobOracle
- 【impdp】資料泵impdp工具選項詳解及應用示例
- 針對資料泵匯出 (expdp) 和匯入 (impdp)工具效能降低問題的檢查表
- impdp/expdp 示例
- oracle expdp and impdpOracle
- 關於資料泵impdp引數驗證(一)
- expdp/impdp使用sysdba許可權遷移資料
- Oracle資料庫的邏輯備份工具-expdp資料泵Oracle資料庫
- 【EXPDP/IMPDP】使用 EXPDP/IMPDP工具“模糊”匯出和匯入