Oracle資料匯入匯出imp exp命令

2021-06-15 22:50:28 字數 2920 閱讀 9097

oracle資料匯入匯出imp/exp就相當於oracle資料還原與備份。exp命令可以把資料從遠端資料庫伺服器匯出到本地的dmp檔案,imp命令可以把dmp檔案從本地匯入到遠處的資料庫伺服器中。

執行環境:可以在sqlplus.exe或者dos(命令列)中執行, dos中可以執行時由於 在oracle 8i 中  安裝目錄ora81bin被設定為全域性路徑, 該目錄下有exp.exe與imp.exe檔案被用來執行匯入匯出。

下面介紹的是匯入匯出的例項。

資料匯出:

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

exp system/manager@test file=d:daochu.dmp full=y

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

exp system/manager@test file=d:daochu.dmp owner=(system,sys)

3 將資料庫中的表inner_notify、notify_staff_relat匯出

exp aichannel/aichannel@testdb2 file= d:datanewsmgnt.dmp tables=(inner_notify,notify_staff_relat) 

4 將資料庫中的表table1中的字段filed1以"00"打頭的資料匯出

exp system/manager@test file=d:daochu.dmp tables=(table1) query=" where filed1 like '00%'"

上面是常用的匯出,對於壓縮,既用winzip把dmp檔案可以很好的壓縮。

也可以在上面命令後面 加上 compress=y 來實現。

資料的匯入

1 將d:daochu.dmp 中的資料匯入 test資料庫中。

imp system/manager@test  file=d:daochu.dmp

imp aichannel/aichannel@hust full=y  file=d:datanewsmgnt.dmp ignore=y

上面可能有點問題,因為有的表已經存在,然後它就報錯,對該錶就不進行匯入。

在後面加上 ignore=y 就可以了。

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

imp system/manager@test  file=d:daochu.dmp  tables=(table1)

基本上上面的匯入匯出夠用了。不少情況要先是將表徹底刪除,然後匯入。

注意:操作者要有足夠的許可權,許可權不夠它會提示。

資料庫時可以連上的。可以用tnsping test 來獲得資料庫test能否連上。

附錄一:

給使用者增加匯入資料許可權的操作

第一,啟動sql*puls

第二,以system/manager登陸

第三,create user 使用者名稱 identified by 密碼 (如果已經建立過使用者,這步可以省略)

第四,grant create user,drop user,alter user ,create any view ,

drop any view,exp_full_database,imp_full_database,

dba,connect,resource,create session  to 使用者名字

第五, 執行-cmd-進入dmp檔案所在的目錄,

imp userid=system/manager full=y file=*.dmp

或者 imp userid=system/manager full=y file=filename.dmp

執行示例:

f:workoracle_databackup>imp userid=test/test full=y file=inner_notify.dmp

螢幕顯示

import: release 8.1.7.0.0 - production on 星期四 2月 16 16:50:05 2006

連線到: oracle8i enterprise edition release 8.1.7.0.0 - production

with the partitioning option

jserver release 8.1.7.0.0 - production

經由常規路徑匯出由export:v08.01.07建立的檔案

已經完成zhs16gbk字符集和zhs16gbk nchar 字符集中的匯入

匯出伺服器使用utf8 nchar 字符集 (可能的ncharset轉換)

. 正在將aichannel的物件匯入到 aichannel

. . 正在匯入表                  "inner_notify"          4行被匯入

準備啟用約束條件...

成功終止匯入,但出現警告。

附錄二:

oracle 不允許直接改變表的擁有者, 利用export/import可以達到這一目的.

先建立import9.par,

然後,使用時命令如下:imp parfile=/filepath/import9.par

例 import9.par 內容如下:

fromuser=tgpms      

touser=tgpms2     (注:把錶的擁有者由fromuser改為touser,fromuser和touser的使用者可以不同)         

rows=y

indexes=y

grants=y

constraints=y

buffer=409600

file==/backup/ctgpc_20030623.dmp

log==/backup/import_20030623.log

補充:在匯入匯出命令中加上feedback=1000可以讓過程顯示乙個不斷增多的「...」,以改變以往的閃爍的游標

oracle 資料備份匯入imp匯出exp

資料的匯出 1 將資料庫test完全匯出,使用者名稱system 密碼manager 匯出到d daochu.dmp中 exp system manager test file d daochu.dmp full y 2.將資料庫中system使用者與sys使用者的表匯出 exp system ma...

Oracle資料庫匯出 exp 匯入 imp

exp damp 檔案,方便資料遷移。但這個過程不能太長,以免回滾段和聯機日誌消耗完 imp 將exp dmp檔案上載到資料庫內。buffer 上載資料緩衝區,以位元組為單位,預設依賴作業系統 commit 上載資料緩衝區中的記錄上載後是否執行提交 feeback 顯示處理記錄條數,預設為0,即不顯...

oracle資料庫匯出 exp 匯入 imp)

單錶備份 前提庫的結構是一樣的 匯出 exp 使用者名稱 密碼 連線字串 grants y tables stu file c 檔名.dmp 匯入 imp 使用者名稱 密碼 連線字串 ignore y tables stu full n file c 檔名.dmp 其中stu是你要的表名 全庫導 匯...