Oracle如何增量導(dǎo)出,如何將oracle數(shù)據(jù)導(dǎo)出來

oracle 10g 怎樣全庫導(dǎo)入、導(dǎo)出?

Oracle數(shù)據(jù)庫有三種標(biāo)準(zhǔn)的備份方法,它們分別是導(dǎo)出/導(dǎo)入(EXP/IMP)、熱備份和冷備份。導(dǎo)出備件是一種邏輯備份,冷備份和熱備份是物理備份。

創(chuàng)新互聯(lián)公司是一家集網(wǎng)站建設(shè),準(zhǔn)格爾企業(yè)網(wǎng)站建設(shè),準(zhǔn)格爾品牌網(wǎng)站建設(shè),網(wǎng)站定制,準(zhǔn)格爾網(wǎng)站建設(shè)報價,網(wǎng)絡(luò)營銷,網(wǎng)絡(luò)優(yōu)化,準(zhǔn)格爾網(wǎng)站推廣為一體的創(chuàng)新建站企業(yè),幫助傳統(tǒng)企業(yè)提升企業(yè)形象加強企業(yè)競爭力??沙浞譂M足這一群體相比中小企業(yè)更為豐富、高端、多元的互聯(lián)網(wǎng)需求。同時我們時刻保持專業(yè)、時尚、前沿,時刻以成就客戶成長自我,堅持不斷學(xué)習(xí)、思考、沉淀、凈化自己,讓我們?yōu)楦嗟钠髽I(yè)打造出實用型網(wǎng)站。

一、 導(dǎo)出/導(dǎo)入(Export/Import)

利用Export可將數(shù)據(jù)從數(shù)據(jù)庫中提取出來,利用Import則可將提取出來的數(shù)據(jù)送回到Oracle數(shù)據(jù)庫中去。

1、 簡單導(dǎo)出數(shù)據(jù)(Export)和導(dǎo)入數(shù)據(jù)(Import)

Oracle支持三種方式類型的輸出:

(1)、表方式(T方式),將指定表的數(shù)據(jù)導(dǎo)出。

(2)、用戶方式(U方式),將指定用戶的所有對象及數(shù)據(jù)導(dǎo)出。

(3)、全庫方式(Full方式),瘵數(shù)據(jù)庫中的所有對象導(dǎo)出。

數(shù)據(jù)導(dǎo)入(Import)的過程是數(shù)據(jù)導(dǎo)出(Export)的逆過程,分別將數(shù)據(jù)文件導(dǎo)入數(shù)據(jù)庫和將數(shù)據(jù)庫數(shù)據(jù)導(dǎo)出到數(shù)據(jù)文件。

2、 增量導(dǎo)出/導(dǎo)入

增量導(dǎo)出是一種常用的數(shù)據(jù)備份方法,它只能對整個數(shù)據(jù)庫來實施,并且必須作為SYSTEM來導(dǎo)出。在進行此種導(dǎo)出時,系統(tǒng)不要求回答任何問題。導(dǎo)出文件名缺省為export.dmp,如果不希望自己的輸出文件定名為export.dmp,必須在命令行中指出要用的文件名。

增量導(dǎo)出包括三種類型:

(1)、“完全”增量導(dǎo)出(Complete)

即備份三個數(shù)據(jù)庫,比如: exp system/manager inctype=complete file=040731.dmp

(2)、“增量型”增量導(dǎo)出

備份上一次備份后改變的數(shù)據(jù),比如: exp system/manager inctype=incremental file=040731.dmp

(3)、“累積型”增量導(dǎo)出

累計型導(dǎo)出方式是導(dǎo)出自上次“完全”導(dǎo)出之后數(shù)據(jù)庫中變化了的信息。比如: exp system/manager inctype=cumulative file=040731.dmp

數(shù)據(jù)庫管理員可以排定一個備份日程表,用數(shù)據(jù)導(dǎo)出的三個不同方式合理高效的完成。

比如數(shù)據(jù)庫的被封任務(wù)可以做如下安排:

星期一:完全備份(A)

星期二:增量導(dǎo)出(B)

星期三:增量導(dǎo)出(C)

星期四:增量導(dǎo)出(D)

星期五:累計導(dǎo)出(E)

星期六:增量導(dǎo)出(F)

星期日:增量導(dǎo)出(G)

如果在星期日,數(shù)據(jù)庫遭到意外破壞,數(shù)據(jù)庫管理員可按一下步驟來回復(fù)數(shù)據(jù)庫:

第一步:用命令CREATE DATABASE重新生成數(shù)據(jù)庫結(jié)構(gòu);

第二步:創(chuàng)建一個足夠大的附加回滾。

第三步:完全增量導(dǎo)入A: imp system/manager inctype=RESTORE FULL=y FILE=A

第四步:累計增量導(dǎo)入E: imp system/manager inctype=RESTORE FULL=Y FILE=E

第五步:最近增量導(dǎo)入F: imp system/manager inctype=RESTORE FULL=Y FILE=F

二、 冷備份

冷備份發(fā)生在數(shù)據(jù)庫已經(jīng)正常關(guān)閉的情況下,當(dāng)正常關(guān)閉時會提供給我們一個完整的數(shù)據(jù)庫。冷備份時將關(guān)鍵性文件拷貝到另外的位置的一種說法。對于備份Oracle信息而言,冷備份時最快和最安全的方法。冷備份的優(yōu)點是:

1、 是非??焖俚膫浞莘椒?只需拷文件)

2、 容易歸檔(簡單拷貝即可)

3、 容易恢復(fù)到某個時間點上(只需將文件再拷貝回去)

4、 能與歸檔方法相結(jié)合,做數(shù)據(jù)庫“最佳狀態(tài)”的恢復(fù)。

5、 低度維護,高度安全。

但冷備份也有如下不足:

1、 單獨使用時,只能提供到“某一時間點上”的恢復(fù)。

2、 再實施備份的全過程中,數(shù)據(jù)庫必須要作備份而不能作其他工作。也就是說,在冷備份過程中,數(shù)據(jù)庫必須是關(guān)閉狀態(tài)。

3、 若磁盤空間有限,只能拷貝到磁帶等其他外部存儲設(shè)備上,速度會很慢。

4、 不能按表或按用戶恢復(fù)。

如果可能的話(主要看效率),應(yīng)將信息備份到磁盤上,然后啟動數(shù)據(jù)庫(使用戶可以工作)并將備份的信息拷貝到磁帶上(拷貝的同時,數(shù)據(jù)庫也可以工作)。冷備份中必須拷貝的文件包括:

1、 所有數(shù)據(jù)文件

2、 所有控制文件

3、 所有聯(lián)機REDO LOG文件

4、 Init.ora文件(可選)

值得注意的使冷備份必須在數(shù)據(jù)庫關(guān)閉的情況下進行,當(dāng)數(shù)據(jù)庫處于打開狀態(tài)時,執(zhí)行數(shù)據(jù)庫文件系統(tǒng)備份是無效的。

下面是作冷備份的完整例子。

(1) 關(guān)閉數(shù)據(jù)庫 sqlplus /nolog

sql;connect /as sysdba

sql;shutdown normal;

(2) 用拷貝命令備份全部的時間文件、重做日志文件、控制文件、初始化參數(shù)文件 sql;cp ; ;

(3) 重啟Oracle數(shù)據(jù)庫 sql;startup

三、 熱備份

熱備份是在數(shù)據(jù)庫運行的情況下,采用archivelog mode方式備份數(shù)據(jù)庫的方法。所以,如果你有昨天夜里的一個冷備份而且又有今天的熱備份文件,在發(fā)生問題時,就可以利用這些資料恢復(fù)更多的信息。熱備份要求數(shù)據(jù)庫在Archivelog方式下操作,并需要大量的檔案空間。一旦數(shù)據(jù)庫運行在archivelog狀態(tài)下,就可以做備份了。熱備份的命令文件由三部分組成:

1. 數(shù)據(jù)文件一個表空間一個表空間的備份。

(1) 設(shè)置表空間為備份狀態(tài)

(2) 備份表空間的數(shù)據(jù)文件

(3) 回復(fù)表空間為正常狀態(tài)

2. 備份歸檔log文件

(1) 臨時停止歸檔進程

(2) log下那些在archive rede log目標(biāo)目錄中的文件

(3) 重新啟動archive進程

(4) 備份歸檔的redo log文件

3. 用alter database bachup controlfile命令來備份控制文件

熱備份的優(yōu)點是:

1. 可在表空間或數(shù)據(jù)庫文件級備份,備份的時間短。

2. 備份時數(shù)據(jù)庫仍可使用。

3. 可達(dá)到秒級恢復(fù)(恢復(fù)到某一時間點上)。

4. 可對幾乎所有數(shù)據(jù)庫實體做恢復(fù)

5. 恢復(fù)是快速的,在大多數(shù)情況下愛數(shù)據(jù)庫仍工作時恢復(fù)。

熱備份的不足是:

1. 不能出錯,否則后果嚴(yán)重

2. 若熱備份不成功,所得結(jié)果不可用于時間點的恢復(fù)

3. 因難于維護,所以要特別仔細(xì)小心,不允許“以失敗告終”。

如何完成Oracle數(shù)據(jù)庫中的數(shù)據(jù)文件(XXX.dmp)導(dǎo)出、導(dǎo)入?

導(dǎo)出表:

exp scott/tiger@mycon tables=(dept,emp) file=tab1.dmp

導(dǎo)出用戶:

exp system/manager@mycon owner=scott file=usr1.dmp

導(dǎo)出數(shù)據(jù)庫:

1.完全導(dǎo)出

exp system/manager@mycon full=y inctype=complete file=full1.dmp

2.增量導(dǎo)出

exp system/manager@mycon full=y inctype=incremental file=inc1.dmp

3.累積導(dǎo)出

exp system/manager@mycon full=y inctype=cumulative file=cum1.dmp

imp example:

導(dǎo)入表:

imp system/manager@mycon file=c:\tab1.dmp tables=(dept,emp) touser=scott

導(dǎo)入用戶:

imp system/manager@mycon file=usr1.dmp fromuser=scott touser=scott

導(dǎo)入數(shù)據(jù)庫:

1.全庫導(dǎo)入

imp system/manager@mycon file=full1.dmp full=y

2.增量導(dǎo)入

1)導(dǎo)入數(shù)據(jù)庫最新信息

imp system/manager@mycon inctype=system full=y file=inc7.dmp

2)導(dǎo)入最近完全導(dǎo)出文件

imp system/manager@mycon inctype=restore full=y file=full1.dmp

3)導(dǎo)入所有累積導(dǎo)出文件

imp system/manager@mycon inctype=restore full=y file=cum1.dmp

4)導(dǎo)入最近一次增量導(dǎo)出的文件

imp system/manager@mycon inctype=restore full=y file=inc1.dmp

oracle怎么批量導(dǎo)入導(dǎo)

需要用exp和imp命令,具體用法如下:

1. 獲取幫助

imp help=y

2. 導(dǎo)入一個完整數(shù)據(jù)庫

imp system/manager file=bible_db log=dible_db full=y ignore=y

3. 導(dǎo)入一個或一組指定用戶所屬的全部表、索引和其他對象

imp system/manager file=seapark log=seapark fromuser=seapark

imp system/manager file=seapark log=seapark fromuser=(seapark,amy,amyc,harold)

4. 將一個用戶所屬的數(shù)據(jù)導(dǎo)入另一個用戶

imp system/manager file=tank log=tank fromuser=seapark touser=seapark_copy

imp system/manager file=tank log=tank fromuser=(seapark,amy)

touser=(seapark1, amy1)

5. 導(dǎo)入一個表

imp system/manager file=tank log=tank fromuser=seapark TABLES=(a,b)

6. 從多個文件導(dǎo)入

imp system/manager file=(paycheck_1,paycheck_2,paycheck_3,paycheck_4)

log=paycheck, filesize=1G full=y

7. 使用參數(shù)文件

imp system/manager parfile=bible_tables.par

bible_tables.par參數(shù)文件:

#Import the sample tables used for the Oracle8i Database Administrator's

Bible. fromuser=seapark touser=seapark_copy file=seapark log=seapark_import

8. 增量導(dǎo)入

imp system./manager inctype= RECTORE FULL=Y FILE=A

-------------------------------------------------------------------------------------------------------------------------------------------

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

分享名稱:Oracle如何增量導(dǎo)出,如何將oracle數(shù)據(jù)導(dǎo)出來
網(wǎng)頁URL:http://muchs.cn/article36/phipsg.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供移動網(wǎng)站建設(shè)、定制開發(fā)網(wǎng)站制作、自適應(yīng)網(wǎng)站、商城網(wǎng)站、動態(tài)網(wǎng)站

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

成都網(wǎng)頁設(shè)計公司