資料泵基礎(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/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Oracle資料泵匯出匯入(expdp/impdp)Oracle
- 使用資料泵(expdp、impdp)遷移資料庫流程資料庫
- 使用impdp,expdp資料泵進入海量資料遷移
- Oracle使用資料泵expdp,impdp進行資料匯出匯入Oracle
- 資料泵datapump(expdp/impdp)的parfile用法,避免跳脫字元字元
- 【Datapump】Oracle資料泵遷移資料命令參考(expdp/impdp說明)Oracle
- Linux下執行資料泵expdp和impdp命令,字元轉義案例兩則Linux字元
- oracle資料庫的impdp,expdpOracle資料庫
- oracle10g expdp資料泵的bug,按schema匯出,匯入impdp時無jobOracle
- Oracle expdp資料泵遠端匯出Oracle
- Oracle資料庫的邏輯備份工具-expdp資料泵Oracle資料庫
- 【資料泵】EXPDP匯出表結構(真實案例)
- 通過dblink,資料泵expdp遠端跨版本導庫
- [20200620]expdp impdp exclude引數.txt
- expdp/impdp變慢 (Doc ID 2469587.1)
- 【Data Pump】expdp/impdp Job基本管理
- expdp/impdp 詳細引數解釋
- ORACLE 資料泵impdp匯入報錯之ORA-31693 ORA-04098Oracle
- impdp和expdp用法及引數介紹
- 【DB筆試面試164】在Oracle中,如何徹底停止expdp資料泵程式?筆試面試Oracle
- ORACLE EXPDP IMPDP 的停止和啟動及監控Oracle
- EXP、IMP、SQLLOADER、EXPDP、IMPDP、DBMS_METADATA、SQLPLUS等方面SQL
- Java程式呼叫expdp資料泵實現自動邏輯備份Oracle資料庫的方案設計JavaOracle資料庫
- ORACLE 資料泵expdp莫名其妙的報錯ORA-31693&ORA-19502&ORA-27063Oracle
- Oracle 12c expdp和impdp匯出匯入表Oracle
- 殺停資料泵
- 資料泵expdp匯出遇到ORA-01555和ORA-22924問題的分析和處理
- 資料庫升級之-資料泵資料庫
- oracle dblink用法總結和expdp和impdp利用dblink倒入匯出到本地Oracle
- 資料泵重建使用者
- 資料泵匯出匯入
- Oracle資料庫(資料泵)遷移方案(上)Oracle資料庫
- Oracle資料庫(資料泵)遷移方案(下)Oracle資料庫
- 資料庫基礎資料庫
- 資料庫 基礎資料庫
- 基礎資料型別資料型別
- 資料庫基礎使用資料庫
- 大資料——HBase基礎大資料
- oracle邏輯備份之--資料泵Oracle