Oracle 資料幫浦匯入匯出總結

2021-08-13 08:58:43 字數 2128 閱讀 3687

oracle資料幫浦匯入匯出是日常工作中常用的基本技術之一,它相對傳統的邏輯匯入匯出要高效,這種特性更適合資料庫物件數量巨大的情形,因為我日常運維的資料庫物件少則幾千,多則幾萬甚至幾十萬,所以傳統exp/imp就會非常耗時,而資料幫浦方式就因此脫引而出,下面就詳細總結一下資料幫浦的使用方法,希望能給初學者帶來幫助。

一、新建邏輯目錄

最好以system等管理員建立邏輯目錄,oracle不會自動建立實際的物理目錄「d:\oracledata」(務必手動建立此目錄),僅僅是進行定義邏輯路徑dump_dir;

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

sql>create directory dump_dir as 'd:\oracledata';

二、檢視管理員目錄(同時檢視作業系統是否存在該目錄,因為oracle並不關心該目錄是否存在,假如不存在,則出錯)

sql>select * from dba_directories;

三、用expdp匯出資料

1)匯出使用者及其物件

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

2)匯出指定表

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

3)按查詢條件導

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

4)按表空間導

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

5)導整個資料庫

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

四、用impdp匯入資料

在正式匯入資料前,要先確保要匯入的使用者已存在,如果沒有存在,請先用下述命令進行新建使用者

--建立表空間

create tablespace tb_name datafile 'd:\tablespace\tb_name.dbf' size 1024m autoextend on;

--建立使用者

create user user_name identified by a123456a default tablespace tb_name temporary tablespace temp;

--給使用者授權

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

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

1)匯入使用者(從使用者scott匯入到使用者scott)

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

2)匯入表(從scott使用者中把錶dept和emp匯入到system使用者中)

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

3)匯入表空間

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

4)匯入資料庫

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

5)追加資料

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

以上是日常工作中實際工作中用到的,希望能夠給你得到幫助。

oracle 資料幫浦匯入匯出

sqlplus system system egov create directory dump dir as d dbback exit expdp system system egov directory dump dir dumpfile urbanyw.dmp schemas urbanyw...

oracle資料幫浦匯入匯出

使用expdp和impdp時應該注意的事項 exp和imp是客戶端工具程式,它們既可以在客戶端使用,也可以在服務端使用。expdp和impdp是服務端的工具程式,他們只能在oracle服務端使用,不能在客戶端使用。imp只適用於exp匯出的檔案,不適用於expdp匯出檔案 impdp只適用於expd...

oracle資料幫浦匯入匯出

1.建立資料幫浦目錄 create directory home as home expdp 2.授權 grant read,write on directory home to scott 資料字典dba directories 3.匯出 全庫匯出 expdp system oracle comp...