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
本站僅提供存儲服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請
點擊舉報。