Oracle導(dǎo)出程序Exp的使用
Oracle的導(dǎo)出實(shí)用程序(Export utility)允許從數(shù)據(jù)庫提取數(shù)據(jù),并且將數(shù)據(jù)寫入操作系統(tǒng)文件。exp使用的基本格式:exp[username[/password[@service>],以下例舉exp常用用法。
1. 獲取幫助
exp help=y
2. 導(dǎo)出一個(gè)完整數(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)出一個(gè)或一組指定用戶所屬的全部表、索引和其他對(duì)象
exp system/manager file=seapark log=seapark owner=seapark exp system/manager file=seapark log=seapark owner=(seapark,amy,amyc,harold)
注意:在導(dǎo)出用戶時(shí),盡管已經(jīng)得到了這個(gè)用戶的所有對(duì)象,但是還是不能得到這些對(duì)象引用的任何同義詞。解決方法是用以下的SQL*Plus命令創(chuàng)建一個(gè)腳本文件,運(yùn)行這個(gè)腳本文件可以獲得一個(gè)重建seapark所屬對(duì)象的全部公共同義詞的可執(zhí)行腳本,然后在目標(biāo)數(shù)據(jù)庫上運(yùn)行該腳本就可重建同義詞了。
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)出一個(gè)或多個(gè)指定表
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. 估計(jì)導(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=fruitUNIX系統(tǒng):
exp system/manager query=\"Where salad_type=\'FRUIT\'\" tables=amy.salad_type file=fruit log=fruit
8. 用多個(gè)文件分割一個(gè)導(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),即備份整個(gè)數(shù)據(jù)庫
exp system/manager inctype=complete file=990702.dmp
- “增量型”增量導(dǎo)出(incremental),即備份上一次備份后改變的數(shù)據(jù)
exp system/manager inctype=incremental file=990702.dmp
- “累計(jì)型”增量導(dǎo)出(cumulative),即備份上一次“完全”導(dǎo)出之后改變的數(shù)據(jù)
exp system/manager inctype=cumulative file=990702.dmp
-
附:常用參數(shù)說明
參數(shù) 說明 file 指定導(dǎo)出文件名。默認(rèn)值是file=expdat.dmp。默認(rèn)的文件擴(kuò)展名是.dmp filesize 允許使用多個(gè)文件分布式導(dǎo)出數(shù)據(jù)。默認(rèn)值為filesize=0,表示所有的數(shù)據(jù)被寫入一個(gè)文件。可以選filesize=1024(1K,1M,1G) full full=y時(shí),表示整個(gè)數(shù)據(jù)庫將被導(dǎo)出。默認(rèn)值為full=n help 控制幫助屏幕的顯示。它的參數(shù)是help=y;沒有help=n選項(xiàng) inctype 指定增量導(dǎo)出選項(xiàng)
1. complete:完全
2. incremental:增量 (導(dǎo)出上次任何導(dǎo)出后改變的所有數(shù)據(jù)庫對(duì)象)
3. cumulative:累計(jì) (導(dǎo)出上次cumulative,complete導(dǎo)出后改變的所有數(shù)據(jù)庫對(duì)象)indexes 指定索引是否被導(dǎo)出。默認(rèn)值為indexes=y。如果不希望索引被導(dǎo)出,用indexes=n log 指定收集導(dǎo)出信息(包括任何錯(cuò)誤信息)的邏輯文件名。默認(rèn)的文件擴(kuò)展名是.log owner 允許為指定用戶或一列用戶導(dǎo)出數(shù)據(jù)和對(duì)象 parfile 允許從一個(gè)文件讀取導(dǎo)出參數(shù) query 指定從一個(gè)或更多的表中導(dǎo)出行的一個(gè)子集。它的參數(shù)值在where語句中,并且被應(yīng)用于select語句,在這里export不導(dǎo)出每一個(gè)表 rows 控制表數(shù)據(jù)是否被導(dǎo)出。默認(rèn)值為rows=y,表示數(shù)據(jù)被導(dǎo)出。rows=n表示只想導(dǎo)出表定義,而不想導(dǎo)出表的數(shù)據(jù) tables 允許導(dǎo)入一個(gè)指定的表或一列表