用戶需要角色exp_full_database和imp_full_database
一、邏輯備份expdp
1.創(chuàng)建目錄對(duì)象
create directory dump_dir as ‘/oracle/datapump/dumps’;
2.授權(quán)目錄對(duì)象
授權(quán)為所有用戶可讀寫
grant read,write on directory dump_dir to public;
授權(quán)為hugwww用戶可讀寫
grant read,write on directory dump_dir to hugwww;
3.查看授權(quán)對(duì)象
select * from dba_directories;
4.導(dǎo)出整個(gè)數(shù)據(jù)庫
expdp system/passwd directory=dump_dir dumpfile=alldb.dmp full=y
或
expdp system/passwd full=y dumpfile=dump_dir:full%U.dmp filesize=2G parallel=2 logfile=dump_dir:full.log job_name=alldb_export
5.對(duì)象模式導(dǎo)出
expdp system/passwd dumpfile=dump_dir:hugwww.dmp logfile=dump_dir:hugwww.log schemas=hugwww
6.表方式導(dǎo)出
expdp system/passwd dumpfile=dump_dir:hugwww_tables.dmp nologfile=y content=metadata_only tables=hugwww.info,hugwww.dept
7.表空間方式導(dǎo)出
expdp system/passwd dumpfile=dump_dir:hugwww_tbs.dmp logfile=dump_dir:hugwww_tbs.log tablespaces=hugwww,hugwww2
二、邏輯恢復(fù)impdp
1.導(dǎo)入表
impdp scott/tiger directory=dump_dir dumpfile=tab.dmp tables=dept,emp
impdp system/manage directory=dump_dir dumpfile=tab.dmp tables=scott.dept,scott.emp remap_schema=SCOTT:SYSTEM
第一種方法表示將DEPT和EMP表導(dǎo)入到SCOTT方案中,第二種方法表示將DEPT和EMP表導(dǎo)入的SYSTEM方案中。
注意,如果要將表導(dǎo)入到其他方案中,必須指定REMAP SCHEMA選項(xiàng)。
2.導(dǎo)入方案
impdp scott/tiger directory=dump_dir dumpfile=schema.dmp schemas=scott
impdp system/manager directory=dump_dir dumpfile=schema.dmp schemas=scott remap_schema=scott:system
3.導(dǎo)入表空間
impdp system/manager directory=dump_dir dumpfile=tablespace.dmp tablespaces=hugwww
4.導(dǎo)入數(shù)據(jù)庫
impdp system/manager directory=dump_dir dumpfile=full.dmp full=y
三、監(jiān)控作業(yè)進(jìn)度
1.命令行操作
數(shù)據(jù)泵導(dǎo)入/導(dǎo)出執(zhí)行后,按ctrl+c進(jìn)入交互模式,輸入:
status
2.查詢dba_datapump_jobs
select owner_name,job_name,operation,state from dba_datapump_jobs;
3.EXPDP/IMPDP的停止與重啟動(dòng)
1)停止任務(wù)
按ctrl+c進(jìn)入交互模式
status
stop_job
2)重新啟動(dòng)任務(wù)
expdp hugwww/passwd attach=alldb_export
start_job
完成!
聯(lián)系客服