expdp與impdp引數用法

2021-07-11 12:00:19 字數 3709 閱讀 7334

一、建立邏輯目錄,該命令不會在作業系統建立真正的目錄,最好以system等管理員建立。

create directory dpdata as 『/opt』;

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

select * from dba_directories;

三、給scott使用者賦予在指定目錄的操作許可權,最好以system等管理員賦予。

grant read,write on directory dpdata1 to scott;

四、匯出資料

1)按使用者導

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

2)並行程序parallel

expdp scott/tiger@orcl directory=dpdata1 dumpfile=scott3.dmp parallel=40 job_name=scott3

3)按表名導

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

4)按查詢條件導

expdp scott/tiger@orcl directory=dpdata1 dumpfile=expdp.dmp tables=emp query=』where deptno=20』;

5)按表空間導

expdp system/manager directory=dpdata1 dumpfile=tablespace.dmp tablespaces=temp,example;

6)導整個資料庫

expdp system/manager directory=dpdata1 dumpfile=full.dmp full=y;

七、引數說明—–匯出expdp

1、content:該選項用於指定要匯出的內容.預設值為all

content=

當設定content為all 時,將匯出物件定義及其所有資料.為data_only時,只匯出物件資料,為metadata_only時,只匯出物件定義

2、directory:指定轉儲檔案和日誌檔案所在的目錄:directory=directory_object

3、exclude:該選項用於指定執行操作時釋放要排除物件型別或相關物件

exclude=object_type[:name_clause] [,….]

object_type用於指定要排除的物件型別,name_clause用於指定要排除的具體物件.exclude和include不能同時使用

expdp scott/tiger directory=dump dumpfile=a.dup exclude=view

4、include:匯出時包含指定的型別

(例:include=table_data,

include=table:」like 『tab%』」

include=table:」not like 『tab%』」…)

exclude:匯出時排除的資料型別(例:exclude=table:emp)

5、filesize:指定匯出檔案的最大尺寸,預設為0,(表示檔案尺寸沒有限制)(單位為bytes).

6、job_name:此次匯出程序使用的名稱,方便跟蹤查詢(可選)

7、flashback_scn:指定匯出特定scn時刻的表資料

flashback_scn=scn_value:scn_value用於標識scn值.flashback_scn和flashback_time不能同時使用

expdp scott/tiger directory=dump dumpfile=a.dmp

flashback_scn=358523

8、flashback_time:指定匯出特定時間點的表資料:flashback_time=「to_timestamp(time_value)」

expdp scott/tiger directory=dump dumpfile=a.dmp flashback_time=「to_timestamp(』25-08-2004 14:35:00』,』dd-mm-yyyy hh24:mi:ss』)」

9、tablespace:指定乙個表空間匯出.

10、query=[schema.] [table_name:] query_clause

schema用於指定方案名,table_name用於指定表名,query_clause用於指定條件限制子句.query選項不能與connect=metadata_only,extimate_only,transport_tablespaces等選項同時使用.

expdp scott/tiger directory=dump dumpfiel=a.dmp tables=emp query=』where deptno=20』

11、parallel:並行操作: 指定執行匯出操作的並行程序個數,預設值為1

您可以通過parallel 引數為匯出使用乙個以上的執行緒來顯著地加速作業。每個執行緒建立乙個單獨的轉儲檔案,因此引數dumpfile 應當擁有和並行度一樣多的專案。您可以指定萬用字元作為檔名,而不是顯式地輸入各個檔名,例如:

expdp ananda/abc123 tables=cases directory=dpdata1 dumpfile=expcases_%u.dmp parallel=4 job_name=cases_export

注意:dumpfile 引數擁有乙個萬用字元%u,它指示檔案將按需要建立,格式將為expcases_nn.dmp,其中nn 從01 開始,然後按需要向上增加。

在並行模式下,狀態螢幕將顯示四個工作程序。(在預設模式下,只有乙個程序是可見的)所有的工作程序同步取出資料,並在狀態螢幕上顯示它們的進度。

分離訪問資料檔案和轉儲目錄檔案系統的輸入/輸出通道是很重要的。否則,與維護data pump 作業相關的開銷可能超過並行執行緒的效益,並因此而降低效能。並行方式只有在表的數量多於並行值並且表很大時才是有效的。

關於direcotry引數:

這個目錄需要有sysdba使用者建立,具體語法見本文最前面,建立完畢後,授權給其他使用者使用,read ,write許可權,然後建立物理目錄

說到這裡,有必要說明一下db建立完畢後,系統有幾個預設的目錄

sql> select * from dba_directories;

owner directory_name

owner directory_name

sys xmldir

c:\ade\aime_dadvfh0169\oracle/rdbms/xml

data_pump_dir這個目錄,是系統預設目錄,如不單獨指定目錄,dmp檔案會在這裡,但預設這個目錄其他使用者是沒有許可權的

以下是應用自己實際匯出專案的sql:

impdp system/laijieyao dumpfile=expdp_20160204.dmp logfile=expdp_20160204.log schemas= ydoatest table_exists_action=replace remap_tablespace=users:ydkf_data remap_schema=ydoatest:ydkf
其中ydoatest是原本匯出庫的使用者,users是原本到出庫的表空間。

ydkf_data是需要導入庫的表空間,ydoatest是需要導入庫的使用者。

expdp與impdp匯出匯入指定表

oracle裡指定匯入匯出表,原本在10g或以前,很簡單的 一 10g或以前 1 匯出指定表 exp sys pwd server1 as sysdba file c temp tables dmp tables schema1.table1,schema1.table2 2 匯入指定表 imp s...

impdp和expdp使用總結

今天在專案中遇到了如下情況 備份恢復一張資料量比較大 大約200w條記錄,約119m大小 的表時,使用慣用的exp imp工具進行操作時,工具直接卡死 或是操作時間過長 於是想起之前使用過的impdp expdp資料幫浦工具,其優點在於大資料量匯入匯出時高效快捷。使用資料幫浦後,漫長的大表匯出過程變...

oracle的expdp和impdp命令研究

建立遠端資料連線 create database link db mzdb11 connect to ytmztwo identified by ytmztwo909 using mzdb11 建立本地目錄 create directory db mz as c 授權使用者讀寫 grant read...