簡說Oracle 數(shù)據(jù)庫導出(exp)/ 導入(imp)
exp
將數(shù)據(jù)庫內的各對象以二進制方式下載成dmp 文件,方便數(shù)據(jù)遷移。
buffer :下載數(shù)據(jù)緩沖區(qū),以字節(jié)為單位,缺省依賴操作系統(tǒng)
consistent :下載期間所涉及的數(shù)據(jù)保持read only,缺省為n
direct :使用直通方式,缺省為n
feeback :顯示處理記錄條數(shù),缺省為0,即不顯示
file:輸出文件,缺省為expdat.dmp
filesize:輸出文件大小,缺省為操作系統(tǒng)最大值
indexes:是否下載索引,缺省為n,這是指索引的定義而非數(shù)據(jù),exp 不下載索引數(shù)據(jù)
log:log 文件,缺省為無,在標準輸出顯示
owner:指明下載的用戶名
query:選擇記錄的一個子集
rows:是否下載表記錄
tables:輸出的表名列表
導出整個實例
exp dbuser/oracle file=oradb.dmp log=oradb.log full=y consistent=y direct=y
user 應具有dba 權限
導出某個用戶所有對象
exp dbuser/oracle file=dbuser.dmp log=dbuser.log owner=dbuser buffer=4096000 feedback=10000
導出一張或幾張表
exp dbuser/oracle file=dbuser.dmp log=dbuser.log tables=table1,table2 buffer=4096000
feedback=10000
導出某張表的部分數(shù)據(jù)
exp dbuser/oracle file=dbuser.dmp log=dbuser.log tables=table1 buffer=4096000 feedback=10000
query=\”where col1=\’…\’ and col2 \<…\”
不可用于嵌套表
以多個固定大小文件方式導出某張表
exp dbuser/oracle file=1.dmp,2.dmp,3.dmp,… filesize=1000m tables=emp buffer=4096000
feedback=10000
這種做法通常用在:表數(shù)據(jù)量較大,單個dump 文件可能會超出文件系統(tǒng)的限制
直通路徑方式
direct=y,取代buffer 選項,query 選項不可用
有利于提高下載速度
consistent 選項
自export 啟動后,consistent=y 凍結來自其它會話的對export 操作的數(shù)據(jù)對象的更新,這樣可以保證
dump 結果的一致性。但這個過程不能太長,以免回滾段和聯(lián)機日志消耗完
imp
將exp 下載的dmp 文件上載到數(shù)據(jù)庫內。
buffer:上載數(shù)據(jù)緩沖區(qū),以字節(jié)為單位,缺省依賴操作系統(tǒng)
commit:上載數(shù)據(jù)緩沖區(qū)中的記錄上載后是否執(zhí)行提交
feeback :顯示處理記錄條數(shù),缺省為0,即不顯示
file:輸入文件,缺省為expdat.dmp
filesize:輸入文件大小,缺省為操作系統(tǒng)最大值
fromuser:指明來源用戶方
ignore:是否忽略對象創(chuàng)建錯誤,缺省為n,在上載前對象已被建立往往是一個正常現(xiàn)象,所以此選項建
議設為y
indexes:是否上載索引,缺省為n,這是指索引的定義而非數(shù)據(jù),如果上載時索引已建立,此選項即使為
n 也無效,imp 自動更新索引數(shù)據(jù)
log:log 文件,缺省為無,在標準輸出顯示
rows:是否上載表記錄
tables:輸入的表名列表
touser:指明目的用戶方
導入整個實例
imp dbuser/oracle file=oradb.dmp log=oradb.log full=y buffer=4096000 commit=y ignore=y
feedback=10000
導入某個用戶所有對象
imp dbuser/oracle file=dbuser.dmp log=dbuser.log fromuser=dbuser touser=dbuser2 buffer=2048000
commit=y ignore=y feedback=10000
導入一張或幾張表
imp dbuser2/oracle file=user.dmp log=user.log tables=table1,table2 fromuser=dbuser
touser=dbuser2 buffer=2048000 commit=y ignore=y feedback=10000
以多個固定大小文件方式導入某張表
imp dbuser/oracle file=\(1.dmp,2.dmp,3.dmp,…\) filesize=1000m tables=emp fromuser=dbuser
touser=dbuser2 buffer=4096000 commit=y ignore=y feedback=10000
Oracle 數(shù)據(jù)庫的備份與恢復
oracle數(shù)據(jù)庫有三種標準的備份方法,它們分別是導出/導入(exp/imp).熱備份與冷備份.導出備件是一種邏輯備份,冷備份與熱備份是物理備份.
利用export可將數(shù)據(jù)從數(shù)據(jù)庫中提取出來,利用import則可將提取出來的數(shù)據(jù)送回到oracle數(shù)據(jù)庫中去.
一. 導出/導入(export/import)
oracle支持三種方式類型的輸出:
1. 簡單導出數(shù)據(jù)(export)與導入數(shù)據(jù)(import)
(1).表方式(t方式),將指定表的數(shù)據(jù)導出.
(2).用戶方式(u方式),將指定用戶的所有對象及數(shù)據(jù)導出.
(3).全庫方式(full方式),瘵數(shù)據(jù)庫中的所有對象導出.
數(shù)據(jù)導入(import)的過程是數(shù)據(jù)導出(export)的逆過程,分別將數(shù)據(jù)文件導入數(shù)據(jù)庫與將數(shù)據(jù)庫數(shù)據(jù)導出到數(shù)據(jù)文件.
2. 增量導出/導入
增量導出是一種常用的數(shù)據(jù)備份方法,它只能對整個數(shù)據(jù)庫來實施,并且必須作為system來導出.在進行此種導出時,系統(tǒng)不要求回答任何問題.導出文件名缺省為export.dmp,如果不希望自己的輸出文件定名為export.dmp,必須在命令行中指出要用的文件名.
增量導出包括三種類型:
(1).“完全”增量導出(complete)exp system/manager inctype=complete file=040731.dmp
即備份三個數(shù)據(jù)庫,比如:
備份上一次備份后改變的數(shù)據(jù),比如:
(2).“增量型”增量導出
exp system/manager inctype=incremental file=040731.dmp
(3).“累積型”增量導出
累計型導出方式是導出自上次“完全”導出之后數(shù)據(jù)庫中變化了的信息.比如:
exp system/manager inctype=cumulative file=040731.dmp
數(shù)據(jù)庫管理員可以排定一個備份日程表,用數(shù)據(jù)導出的三個不同方式合理高效的完成.
比如數(shù)據(jù)庫的被封任務可以做如下安排:
星期一:完全備份(a)
星期二:增量導出(b)
星期三:增量導出(c)
星期四:增量導出(d)
星期五:累計導出(e)
星期六:增量導出(f)
星期日:增量導出(g)