Oracle導(dǎo)出程序Exp的使用
Oracle的導(dǎo)出實用程序(Export utility)允許從數(shù)據(jù)庫提取數(shù)據(jù),并且將數(shù)據(jù)寫入操作系統(tǒng)文件。exp使用的基本格式:exp[username[/password[@service>],以下例舉exp常用用法。
1. 獲取幫助
exp help=y
2. 導(dǎo)出一個完整數(shù)據(jù)庫
exp system/manager file=bible_db log=dible_db full=y
3. 導(dǎo)出數(shù)據(jù)庫定義而不導(dǎo)出數(shù)據(jù)
exp system/manager file=bible_db log=dible_db full=y rows=n
4. 導(dǎo)出一個或一組指定用戶所屬的全部表、索引和其他對象
exp system/manager file=seapark log=seapark owner=seapark
exp system/manager file=seapark log=seapark owner=(seapark,amy,amyc,harold)
注意:在導(dǎo)出用戶時,盡管已經(jīng)得到了這個用戶的所有對象,但是還是不能得到這些對象引用的任何同義詞。解決方法是用以下的SQL*Plus命令創(chuàng)建一個腳本文件,運行這個腳本文件可以獲得一個重建seapark所屬對象的全部公共同義詞的可執(zhí)行腳本,然后在目標(biāo)數(shù)據(jù)庫上運行該腳本就可重建同義詞了。
SET LINESIZE 132
SET PAGESIZE 0
SET TRIMSPOOL ON
SPOOL c:\seapark.syn
SELECT 'Create public synonym '||synonym_name
||' for '||table_owner||'.'||table_name||';'
FROM dba_synonyms
WHERE table_owner = 'SEAPARK' AND owner = 'PUBLIC';
SPOOL OFF
5. 導(dǎo)出一個或多個指定表
exp seapark/seapark file=tank log=tank tables=tank
exp system/manager file=tank log=tank tables=seapark.tank
exp system/manager file=tank log=tank tables=(seapark.tank,amy.artist)
6. 估計導(dǎo)出文件的大小
全部表總字節(jié)數(shù):
SELECT sum(bytes)
FROM dba_segments
WHERE segment_type = 'TABLE';
seapark用戶所屬表的總字節(jié)數(shù):
SELECT sum(bytes)
FROM dba_segments
WHERE owner = 'SEAPARK'
AND segment_type = 'TABLE';
seapark用戶下的aquatic_animal表的字節(jié)數(shù):
SELECT sum(bytes)
FROM dba_segments
WHERE owner = 'SEAPARK'
AND segment_type = 'TABLE'
AND segment_name = 'AQUATIC_ANIMAL';
7. 導(dǎo)出表數(shù)據(jù)的子集(oracle8i以上)
NT系統(tǒng):
exp system/manager query='Where salad_type=''FRUIT''' tables=amy.salad_type
file=fruit log=fruit
UNIX系統(tǒng):
exp system/manager query=\"Where salad_type=\'FRUIT\'\" tables=amy.salad_type
file=fruit log=fruit
8. 用多個文件分割一個導(dǎo)出文件
exp system/manager
file=(paycheck_1,paycheck_2,paycheck_3,paycheck_4)
log=paycheck, filesize=1G tables=hr.paycheck
9. 使用參數(shù)文件
exp system/manager parfile=bible_tables.par
bible_tables.par參數(shù)文件:
#Export the sample tables used for the Oracle8i Database Administrator's Bible.
file=bible_tables
log=bible_tables
tables=(
amy.artist
amy.books
seapark.checkup
seapark.items
)
10. 增量導(dǎo)出
- “完全”增量導(dǎo)出(complete),即備份整個數(shù)據(jù)庫
exp system/manager inctype=complete file=990702.dmp
- “增量型”增量導(dǎo)出(incremental),即備份上一次備份后改變的數(shù)據(jù)
exp system/manager inctype=incremental file=990702.dmp
- “累計型”增量導(dǎo)出(cumulative),即備份上一次“完全”導(dǎo)出之后改變的數(shù)據(jù)
exp system/manager inctype=cumulative file=990702.dmp
-
附:常用參數(shù)說明
參數(shù) |
說明 |
file |
指定導(dǎo)出文件名。默認值是file=expdat.dmp。默認的文件擴展名是.dmp |
filesize |
允許使用多個文件分布式導(dǎo)出數(shù)據(jù)。默認值為filesize=0,表示所有的數(shù)據(jù)被寫入一個文件。可以選filesize=1024(1K,1M,1G) |
full |
full=y時,表示整個數(shù)據(jù)庫將被導(dǎo)出。默認值為full=n |
help |
控制幫助屏幕的顯示。它的參數(shù)是help=y;沒有help=n選項 |
inctype |
指定增量導(dǎo)出選項
1. complete:完全
2. incremental:增量 (導(dǎo)出上次任何導(dǎo)出后改變的所有數(shù)據(jù)庫對象)
3. cumulative:累計 (導(dǎo)出上次cumulative,complete導(dǎo)出后改變的所有數(shù)據(jù)庫對象)
|
indexes |
指定索引是否被導(dǎo)出。默認值為indexes=y。如果不希望索引被導(dǎo)出,用indexes=n |
log |
指定收集導(dǎo)出信息(包括任何錯誤信息)的邏輯文件名。默認的文件擴展名是.log |
owner |
允許為指定用戶或一列用戶導(dǎo)出數(shù)據(jù)和對象 |
parfile |
允許從一個文件讀取導(dǎo)出參數(shù) |
query |
指定從一個或更多的表中導(dǎo)出行的一個子集。它的參數(shù)值在where語句中,并且被應(yīng)用于select語句,在這里export不導(dǎo)出每一個表 |
rows |
控制表數(shù)據(jù)是否被導(dǎo)出。默認值為rows=y,表示數(shù)據(jù)被導(dǎo)出。rows=n表示只想導(dǎo)出表定義,而不想導(dǎo)出表的數(shù)據(jù) |
tables |
允許導(dǎo)入一個指定的表或一列表 |
|
posted on 2009-05-30 18:19
小虎(年輕) 閱讀(420)
評論(0) 編輯 收藏 所屬分類:
Oracle相關(guān)