Oracle11g expdp匯出 impdp匯入

2021-06-23 09:56:51 字數 3902 閱讀 8380

以sys等管理員身份建立邏輯目錄

create directory dpedu as '/db/dmp_bk/edu';

檢視管理理員目錄

select * from dba_directories;

給使用者賦予在指定目錄的操作許可權

grant read,write on directory dpedu to edu_test_jyj;

匯出資料

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;

匯入資料

1)導到指定使用者下

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

2)改變表的owner

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

3)匯入表空間

impdp system/manager directory=dpdata1 dumpfile=tablespace.dmp tablespaces=example;

4)匯入資料庫

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

5)追加資料

impdp system/manager directory=dpdata1 dumpfile=expdp.dmp schemas=system table_exists_action

引數說明-----匯入impdp

2、remap_schema

該選項用於將源方案的所有物件裝載到目標方案中:remap_schema=source_schema:target_schema

3、remap_tablespace

將源表空間的所有物件匯入到目標表空間中:remap_tablespace=source_tablespace:target:tablespace

4、remap_datafile

該選項用於將源資料檔名轉變為目標資料檔名,在不同平台之間搬移表空間時可能需要該選項.

remap_datafiel=source_datafie:target_datafile

引數說明-----匯出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 作業相關的開銷可能超過並行執行緒的效益,並因此而降低效能。並行方式只有在表的數量多於並行值並且表很大時才是有效的。

關於oracle11gexpdp問題

sql create or replace directory dump dir 2 as d oracle dump 目錄已建立。使用者指將使用expdp的使用者sql grant 2 read,write on directorydump dir to hr 授權成功。每次只能匯出乙個模式中的表...

oracle 如何 導表

兩種方式 第一種方便 第一種執行匯入沒有反應的話 可以用第二種。1.方法一 利用pl sql developer工具匯出 選單欄 1,開啟 開始 輸入cmd 2,將d daochu.dmp 中的資料匯入 test資料庫中。在此之前,要明確,使用者名稱 此例 system 密碼 manager 例項名...

解決ORACLE11g匯出表不全問題及匯入匯出

一 因oracle11對未占有空間記憶體的表 即未用過的表 不進行匯出,所以在進行exp時只匯出的表會不全。檢查user tables表發現沒有匯出的表的segment created屬性是no 解決辦法 1 可通過下面語句生成sql執行 select alter table table name ...