1. 程式人生 > >expdp和impdp數據泵

expdp和impdp數據泵

expdp和impdp數據泵

COMPRESSION={METADATA_ONLY | NONE} --數據壓縮

CONTENT={ALL | DATA_ONLY | METADATA_ONLY} --指定導出的內容(當設置CONTENT為ALL時,會導出對象元數據及對象數據;當設置為DATA_ONLY時,只導出對象數據;當設置為METADATA_ONLY時,只導出對象元數據。)

DIRECTORY=directory_object --備份文件存儲的路徑

DUMPFILE=[directory_object:]file_name [, ...] --directory_object用於指定目錄對象名,file_name用於指定轉儲文件名。如果不給定directory_object,導出工具會自動使用DIRECTORY選項指定的目錄對象。

ESTIMATE={BLOCKS | STATISTICS} --設置為BLOCKS時,oracle會按照目標對象所占用的數據塊個數乘以數據塊尺寸估算對象占用的空間;設置為STATISTICS時,會根據最近的統計值給出對象占用空間,這種方法的誤差會比較大。無論使用哪種選項值,都會有誤差。

ESTIMATE_ONLY={y | n} --指定是否只估算導出作業所占用的磁盤空間,默認值為N

EXCLUDE=object_type[:name_clause] [, ...] --用於控制在導出過程中哪些數據庫對象不被導出。(object_type用於指定要排除的對象類型,name_clause用於指定要排除的具體對象名稱。註意EXCLUDE選項和INCLUDE選項不能同時使用。

)

FILESIZE=integer[B | K | M | G] --限定單個轉儲文件的最大容量,默認值是0,表示沒有文件尺寸的限制。該選項與DUMPFILE選項一同使用。

FULL={y | n} --是否以全庫模式導出數據庫。默認為N。

LOGFILE=[directory_object:]file_name --指定導出過程中日誌文件的名稱,默認值為export.log。

PARALLEL=integer --指定執行導出操作的並行度,默認值為1。

SCHEMAS=schema_name [, ...] --按照SCHEMA模式導出,默認為當前用戶。很常用,不做更多的解釋。

TABLES=[schema_name.]table_name[:partition_name] [, ...] --schema_name用於指定用戶名,table_name用於指定導出的表名,partition_name用於指定要導出的分區名。

TABLESPACES=tablespace_name [, ...] --指定需要導出哪個表空間中的表數據。



1.創建備份或者恢復目錄

SQL> create directory tong as ‘/u01‘;

Directory created.

SQL> grant read,write on directory tong to USERCTLDEV;

Grant succeeded.

SQL> select * from dba_directories where directory_name=‘TONG‘;

OWNER DIRECTORY_NAME DIRECTORY_PATH

SYS TONG /u01

SQL>


2.按用戶導出數據

expdp scott/tiger schemas=scott dumpfile=scott.dmp logfile=scott.log directory=tong;


3.按用戶並行度導出數據

expdp scott/tiger schemas=scott dumpfile=scott.dmp logfile=scott.log directory=tong parallel=40


4.按表名導出數據

expdp scott/tiger tables=emp,dept dumpfile=scott.dmp logfile=scott.log directory=tong


5.按表名和帶條件導出數據

expdp scott/tiger tables=emp query=‘where deptno=20‘ dumpfile=scott.dmp logfile=scott.log directory=tong


6.按表空間導出數據

expdp scott/tiger tablespace=temp,example dumpfile=scott.dmp logfile=scott.log directory=tong


7.導出整個數據庫

expdp system/manager directory=tong dumpfile=full.dmp FULL=y


8.將scott用戶的數據導入到scott用戶下

impdp scott/tiger directory=tong dumpfile=expdp.dmp schemas=scott


9.將scott用戶下的dept表導入到system用戶下

impdp system/manager directory=tong dumpfile=expdp.dmp tables=scott.dept remap_schema=scott:system


10.導入表空間

impdp system/manager directory=tong dumpfile=tablespace.dmp tablespace=example


11.導入數據庫

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


12.將scoot用戶下的abc表空間的數據導入到system用戶下的bcd表空間

impdp scott/tiger directory=tong dumpfile=scott.dmp logfile=scott.log remap_schema=scott:system remap_tablespace=abc:bcd


13.如果表空間已存在的表,導入數據有4種情況

TABLE_EXISTS_ACTION=對應以下四個值

SKIP 不管已存在的表,直接跳過

APPEND 保持現有的數據,導入新數據

TRUNCATE 刪除原有的數據,導入新數據

REPLACE 刪除所有表(drop),並重建(create),再導入新數據


本文出自 “一起走過的日子” 博客,請務必保留此出處http://tongcheng.blog.51cto.com/6214144/1976317

expdp和impdp數據泵