oracle10g_expdp工具測試學習_之一

wisdomone1發表於2009-09-09
Normal 0 7.8 磅 0 2 false false false MicrosoftInternetExplorer4 1,  術語簡解

Expdporacle10g新引入的僅用於伺服器端的邏輯匯出工具,其功能相當強大

Expdp help=y  可以檢視其詳細用法,更多資訊,請參看oracle官方文件

Expdp匯出的檔案是以二進位制方式儲存,和exp工具的檔案不能混用

 

Expdp不同於exp,他是以伺服器端執行,所以在執行操作前先要在oracle在構建一個directory的物件,可以理解為:儲存匯出檔案的目錄(這個目錄先要在作業系統上建好)

2,  測試步驟

Expdp可以以下幾種模式進行資料匯出

 

Full Export Mode---全庫匯出,類似於9iexp full=y

   執行操作的使用者必須要具備exp_full_database許可權

  關鍵字為:full=y

Schema Mode—匯出某個使用者或多個使用者(如匯出多個使用者,以,分隔),這是預設的匯出模式

   關鍵字為:schemas=匯出的使用者

 

Table Mode  ---匯出某些表或特定表

    關鍵字為:tables

Tablespace Mode  ---匯出某些表空間或某個表空間

    必須具備exp_full_database角色

    關鍵字為:tablespaces

Transportable Tablespace Mode  --這個用於跨資料庫表空間遷移,其實就是把表空間從一個資料庫遷移到另一個資料庫

   關鍵字為:transfort_tablespaces=要匯出的表空間

             Transfort_full_check   -- 用於在匯出時是否驗證匯出物件存在引用性,通俗點就是說:比如表在儲存在一個表空間,但表上的索引在另一個表空間,像這種引用性物件是不可以匯出的,除非你把所有的物件全部匯出

另外:必須具有exp_full_database角色

      僅匯出表空間的後設資料(可以理解為資料庫底層的建立物件的ddl語句之類)

      匯出的資料集必須是自包含的,就是說匯出的物件必須只能在一個表空間

中,不能跨多個表空間存在

              此模式下匯出job一旦停止,不能重新開始執行

              此模式並行度(parallel)不能>1

 

 

各匯出模式示例如下:

expdp system/system full=y dumpfile=test_expdp:fulldb_new.dmp  ---全庫匯出

 

expdp zxy/system tablespaces=sysaux dumpfile=test_expdp:exp_sysaux.dmp  ---匯出表空間

 

expdp zxy/system schemas=zxy,fs1,trans dumpfile=test_expdp:exp_multi_user.dmp –匯出使用者(模式)

 

expdp zxy/system tables=mv dumpfile=test_expdp:exp_table.dmp  ---匯出表

 

 

SAMPLE                Percentage of data to be exported;

詳細請參下

expdp zxy/system tables=mv sample=30 dumpfile=test_expdp:test_per.dmp –匯出部分資料子集

 

 

 

 

這個引數唯一的用處就是壓縮匯出檔案集的大小,可以節省儲存, 呵呵

COMPRESSION           Reduce size of dumpfile contents where valid

                      keyword values are: (METADATA_ONLY) and NONE.

 

expdp zxy/system compression=metadata_only  dumpfile=test_expdp:test_com_meta.dmp

expdp zxy/system compression=none  dumpfile=test_expdp:test_com.dmp

 

 

 

CONTENT               Specifies data to unload where the valid keywords are:

                      ALL  ---匯出資料和後設資料

                      DATA_ONLY, --僅匯出資料

METADATA_ONLY.  僅匯出後設資料

 

 

expdp zxy/system dumpfile=test_expdp:test_content_data.dmp content=data_only

 

 

 

這個estimate就是檢視匯出表資料到底佔多大的儲存空間

Specifies the method that Export will use to estimate how much disk space each table in the export job will consume (in bytes). The estimate is for table row data only; it does not include metadata

 

ESTIMATE              Calculate job estimates where the valid keywords are:

                      (BLOCKS) and STATISTICS.

 

expdp zxy/system estimate=blocks dumpfile=test_expdp:test_estimate_blocks.dmp

如果estimate等於statistics,得到的值更為精確,但一定要先用dbms_stats進行對應的分析

 

 

 

這個引數用於不實際執行匯出操作,評估下到底以表模式匯出要佔用多大的儲存空間

ESTIMATE_ONLY         Calculate job estimates without performing the export.

expdp zxy/system  tables=mv,sex estimate_only=y estimate=statistics

 

 

 

 

這個引數用於在job在開啟多少個並行程式,oracle建議開啟並行程式數量和匯出檔案一樣,這樣效能最佳

Parallel

Enables you to increase or decrease the number of active worker processes for the current job.

 

 

這個引數用於控制每個匯出檔案集的大小,說白了就是克服作業系統的檔案系統限制

FILESIZE=number 

The file size can be followed by B, K, M, or G to indicate that the size is expressed in bytes, kilobytes, megabytes, or gigabytes, respectively. The default is B.

A file size of 0 indicates that there will not be any size restrictions on new dump files. They will be extended as needed until the limits of the containing device are reached

 

expdp zxy/system  dumpfile=test_expdp:test_p%U filesize=2m  parallel=10

 

 

logfile ---此引數類同於exp中的log,就是記錄匯出操作的日誌,另:logfile一定在儲存在預先建立的directory物件中

expdp zxy/system dumpfile=test_expdp:test_sch.dmp logfile=other:test_log.log

 

 include –這個引數就是控制只匯出什麼物件,注意塗黃部分一定要大寫,不然會報錯,

        此引數與exclude引數不能同時使用

expdp zxy/system dumpfile=other:test_part.dmp include=TABLE:"IN('MV')"

 

query ---只匯出表資料部分子集,其實就是select中的where子句,單引號裡含雙引號,且命令謂語一定要大寫,不然會報錯

expdp zxy/system dumpfile=other:test_part_query.dmp tables=mv query=mv:'"WHERE a=3"'

 

expdp zxy/system dumpfile=other:test_full_db.dmp full=y job_name=exp_full_db

 --也可以從dba_datapump_jobs檢視資料匯出job的相關資訊

ctrl+c進入互動匯出模式

Export>stop_job   ---此時job狀態為not running

 

expdp zxy/system attach=exp_full_job ---重新附加這個停止的job,同時進入export互動模式

Export> start_job  --此時job狀態為executing

Export>kill_job   ---殺掉這個job,再想恢復就不行了喲

Export>continue_client  ---退出互動匯出模式,進入記錄匯出操作日誌狀態

Export>exit_client   ---退出互動匯出模式,但匯出操作job仍在操作中

 

利用引數檔案匯出,這個一般用於為了規避麻煩的在命令列模式出現一些特殊字元

more test.par

dumpfile=other:test_schema.dmp

logfile=test_expdp:test_log2.log

 

expdp zxy/system parfile=/oracle/test.par



---連線字串@和network_link的學習

ora-02085  構建資料庫連結
 處理:alter system set db_domain='' scope=spfile;startup force
      alter system set

ORA-31631: 需要許可權
ORA-39149: 無法將授權使用者連結到非授權使用者

create user test identified by test
default tablespace users

grant connect to test;
grant create table, create database link to test;
grant read, write on directory windir to test;

conn test/test
create database link test113 connect to lk identified by system
using 'vm'; --vm是客戶端中構建連線目標資料庫的連結字串

expdp中的network_link就是在源資料庫(本地資料庫),透過link 把遠端資料庫的轉儲檔案(dumpfile)儲存在本地資料庫
expdp user/password@連結字串 --這個和上面的network_link又不同,它是透過本地資料庫連線到遠端資料庫,
                               --轉儲檔案還是生成在遠端資料庫中

 

 

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/9240380/viewspace-614235/,如需轉載,請註明出處,否則將追究法律責任。

相關文章