ORACLE的EXP與IMP常用整理

2021-06-19 13:35:03 字數 3620 閱讀 5539

關於oracle資料的匯出與匯入,是在工作中經常用到,尤其是資料庫備份。

exp與imp的用法收集網路,還是那句話,「出來混的,總是要還的」 。

一.定義

oracle 的exp/imp命令用於實現對資料庫的匯出/匯入操作;

exp命令用於把資料從遠端資料庫伺服器匯出至本地,生成dmp檔案;

imp命令用於把本地的資料庫dmp檔案從本地匯入到遠端的oracle資料庫中。

二.語法格式

格式:匯出

> exp userid/password@instance file='path' log='log.log' 引數

匯入》 imp userid/password@instance file='path' log='log.log' 引數

cmd命令列輸入 imp help=y 或 exp help=y 獲取imp或exp的語法引數資訊:

userid   使用者名稱/口令          

full     匯入整個檔案 (n)

buffer   資料緩衝區大小        

fromuser     所有人使用者名稱列表

file     輸入檔案 (expdat.dmp)   

touser       使用者名稱列表

show     只列出檔案內容 (n)

tables      表名列表

ignore   忽略建立錯誤 (n)   

recordlength  io 記錄的長度

grants   匯入許可權 (y)          

inctype      增量匯入型別

indexes  匯入索引 (y)         

commit       提交陣列插入 (n)

rows     匯入資料行 (y)       

parfile      引數檔名

log      螢幕輸出的日誌檔案  

constraints  匯入限制 (y)

destroy                覆蓋表空間資料檔案 (n)

indexfile              將表/索引資訊寫入指定的檔案

skip_unusable_indexes  跳過不可用索引的維護 (n)

feedback               每 x 行顯示進度 (0)

toid_novalidate        跳過指定型別 id 的驗證

filesize               每個轉儲檔案的最大大小

statistics             始終匯入預計算的統計資訊

resumable              遇到與空格有關的錯誤時掛起 (n)

resumable_name         用來標識可恢復語句的文字字串

resumable_timeout      resumable 的等待時間

compile                編譯過程, 程式包和函式 (y)

1) 資料匯出:

1 將資料庫sampledb完全匯出,使用者名稱system 密碼manager 匯出到e:/sampledb.dmp中

exp system/manager@testdb file=e:/sampledb.dmp log=e:/sample.log full=y

2 將資料庫中system使用者與sys使用者的表匯出

exp system/manager@testdb file=e:/sampledb.dmp  log=e:/sample.log owner=(system,sys)

3 將資料庫中的表 tablea,tableb 匯出

exp system/manager@testdb  file=e:/sampledb.dmp  log=e:/sample.log tables=(tablea,tableb)

4 將資料庫中的表tablea中的字段filed1 值為 "王五" 的資料匯出

exp system/manager@testdb  file=e:/sampledb.dmp log=e:/sample.log tables=(tablea)  query=' where filed1='王五'

如果想對dmp檔案進行壓縮,可以在上面命令後面 加上 compress=y 來實現。

如果想只匯出資料庫物件的結構,引數加rows=no 獲得,全部物件 full=y,忽略各種錯誤 ignore=y

2) 資料的匯入

1 將備份資料庫檔案中的資料匯入指定的資料庫sampledb 中,如果 sampledb 已存在該錶,則不再匯入;

imp system/manager@test  file=e:/sampledb.dmp log=e:/sample.log full=y  ignore=y

2 將d:/daochu.dmp中的表table1 匯入

imp system/manager@test  file=e:/sampledb.dmp log=e:/sample.log  tables=(table1)

3. 匯入乙個完整資料庫

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

4. 匯入乙個或一組指定使用者所屬的全部表、索引和其他物件

imp system/manager file=e:/sampledb.dmp log=e:/sample.log fromuser=seapark

imp system/manager file=e:/sampledb.dmp log=e:/sample.log fromuser=(seapark,amy,amyc,harold)

5. 將乙個使用者所屬的資料匯入另乙個使用者

imp system/manager file=e:/sampledb.dmp log=e:/sample.log fromuser=seapark touser=seapark_copy

imp system/manager file=e:/sampledb.dmp log=e:/sample.log fromuser=(seapark,amy)

touser=(seapark1, amy1)

6. 匯入乙個表

imp system/manager file=e:/sampledb.dmp log=e:/sample.log fromuser=seapark tables=(a,b)

7. 從多個檔案匯入

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

log=paycheck, filesize=1g full=y

8. 使用引數檔案

imp system/manager parfile=bible_tables.par

bible_tables.par引數檔案:

#import the sample tables used for the oracle8i database administrator's

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

9. 增量匯入

imp system./manager inctype= rectore full=y  file=a

oracle 的exp和imp命令

我們通常要對oracle的資料進行匯入,匯出,在沒有expdb,impdb以前 10g以前 我們都是使用exp 匯出,imp命令來實現匯入。開啟cmd視窗,實現imp,exp主要是sqlplus.exe呼叫imp.exe,exp.exe來完成的。下面是幾個常用的關於exp,imp命令的一些舉例 1完...

oracle使用exp與imp對資料遷移備份的方法

使用exp和imp命令是oracle對資料進行遷移備份的一種最簡單最常用的一種方式。在此記錄下使用的方法步驟,以備後用。首先,在老庫上使用命令 exp userid username password database owner file dmp log log 其中 後面的database是資料...

oracle的exp和imp命令的使用

我們通常要對oracle的資料進行匯入,匯出,在沒有expdb,impdb以前 10g以前 我們都是使用exp 匯出,imp命令來實現匯入。開啟cmd視窗,實現imp,exp主要是sqlplus.exe呼叫imp.exe,exp.exe來完成的。下面是幾個常用的關於exp,imp命令的一些舉例 1 ...