Oracle簡單常用的數(shù)據(jù)泵導(dǎo)出導(dǎo)入(expdp/impdp)命令舉例

一、新建邏輯目錄

最好以system等管理員創(chuàng)建邏輯目錄,Oracle不會自動創(chuàng)建實(shí)際的物理目錄“D:\oracleData”(務(wù)必手動創(chuàng)建此目錄),僅僅是進(jìn)行定義邏輯路徑dump_dir;

? ? ?sql>?conn system/123456a?@orcl as sysdba;

? ? ?sql>create directory dump_dir as 'D:\oracleData';

二、查看管理員目錄(同時查看操作系統(tǒng)是否存在該目錄,因為oracle并不關(guān)心該目錄是否存在,假如不存在,則出錯)

? ? ?sql>select * from dba_directories;

三、用expdp導(dǎo)出數(shù)據(jù)

1)導(dǎo)出用戶及其對象

expdp scott/tiger@orcl schemas=scott dumpfile=expdp.dmp directory=dump_dir;

2)導(dǎo)出指定表

expdp scott/tiger@orcl tables=emp,dept dumpfile=expdp.dmp directory=dump_dir;

3)按查詢條件導(dǎo)

expdp scott/tiger@orcl directory=dump_dir dumpfile=expdp.dmp tables=empquery='where deptno=20';

4)按表空間導(dǎo)

expdp system/manager@orcl directory=dump_dir dumpfile=tablespace.dmptablespaces=temp,example;

5)導(dǎo)整個數(shù)據(jù)庫

expdp system/manager@orcl directory=dump_dir dumpfile=full.dmp full=y;

四、用impdp導(dǎo)入數(shù)據(jù)

? ?在正式導(dǎo)入數(shù)據(jù)前,要先確保要導(dǎo)入的用戶已存在,如果沒有存在,請先用下述命令進(jìn)行新建用戶

--創(chuàng)建表空間

create tablespace tb_name datafile 'D:\tablespace\tb_name.dbf' size 1024m AUTOEXTEND ON;

--創(chuàng)建用戶

create user user_name identified by A123456a default tablespace tb_name?temporary tablespace TEMP;

--給用戶授權(quán)

sql>grant read,write on directory dump_dir?to user_name;

sql>grant dba,resource,unlimited tablespace to user_name;

1)導(dǎo)入用戶(從用戶scott導(dǎo)入到用戶scott)

impdp scott/tiger@orcl directory=dump_dir dumpfile=expdp.dmp schemas=scott;

2)導(dǎo)入表(從scott用戶中把表dept和emp導(dǎo)入到system用戶中)

impdp system/manager@orcl directory=dump_dir dumpfile=expdp.dmptables=scott.dept,scott.emp remap_schema=scott:system;

3)導(dǎo)入表空間

impdp system/manager@orcl directory=dump_dir dumpfile=tablespace.dmp tablespaces=example;

4)導(dǎo)入數(shù)據(jù)庫

impdb system/manager@orcl directory=dump_dir dumpfile=full.dmp full=y;

5)追加數(shù)據(jù)

impdp system/manager@orcl directory=dump_dir dumpfile=expdp.dmp schemas=systemtable_exists_action

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

友情鏈接更多精彩內(nèi)容