數據泵技術是Oracle Database 10g 中的新技術,它比原來導入/導出(imp,exp)技術快15-45倍。速度的提高源於使用了並行技術來讀寫導出轉儲文件。
ORACLE使用EXPDP和IMPDP數據泵進行導出導入的方法
使用expdp和impdp時應該注重的事項:
1、exp和imp是客戶端工具程序,它們既可以在客戶端使用,也可以在服務端使用。
2、expdp和impdp是服務端的工具程序,他們只能在oracle服務端使用,不能在客戶端使用。
3、imp只適用於exp導出的文件,不適用於expdp導出文件;impdp只適用於expdp導出的文件,而不適用於exp導出文件。
4、對於10g以上的服務器,使用exp通常不能導出0行數據的空表,而此時必須使用expdp導出。
一、創建邏輯目錄,該命令不會在操作系統創建真正的目錄(請先創建真正的目錄),最好以system等管理員創建邏輯目錄。
SQL>conn system/manger@orcl as sysdba
SQL>create directory dump_dir as 'd:\test\dump';
二、查看管理員目錄(同時查看操作系統是否存在,因爲oracle並不關心該目錄是否存在,假如不存在,則出錯)
SQL>select * from dba_directories;
三、給scott用戶賦予在指定目錄的操作權限,最好以system等管理員賦予。
SQL>grant read,write on directory dump_dir to scott;
四、用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導入數據
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
在任何項目中,數據是最重要的,切記一定事先規劃好備份空間,及時的關注備份狀態。