Orcale Database Backup資料的命令用exp.exe,還原資料庫命令imp.exe
一、備份資料庫——exp
格式:exp 使用者名稱/密碼@資料庫 owner=擁有者 file=C:\xxx\xxx.dmp
eg1、資料庫TEST完全匯出,使用者名稱:test, 密碼:test,擁有者:tb_test 匯出到D:\daochu.dmp中
exp test/test@TEST owner=tb_test file=d:\daochu.dmp
第一步:進入到 Oracle 安裝目錄下的bin目錄下;
第二步:exp test/test@TEST owner=tb_test file=d:\daochu.dmp
eg2、將資料庫中的表test中的欄位filed1以"00"開頭的資料匯出,使用者名稱:test, 密碼:test
exp test/test@TEST file=d:\daochu.dmp tables=(test)query="where filed1 like '00%'"
註:可以在命令後面 加上 compress=y 來實現 檔案壓縮
二、還原資料庫——imp
格式:imp 使用者名稱/密碼@資料庫 full=y file=備份檔案路徑 ignore=y log=記錄檔路徑
eg 1、將D:\daochu.dmp檔案還原到tb_test資料庫中,使用者名稱:test, 密碼:test,記錄檔放在D:/log.txt 中
第一步:進入到 oracle 安裝目錄下的bin目錄下;
第二步:imp system/manager@tb_test full = y file="d:\back.dmp" ignore=y log=d:\log.txt
eg2、將d:\daochu.dmp中的表table1 匯入到tb_test資料庫中
imp system/manager@tb_test file=d:\daochu.dmp tables=(table1)
註:如何沒有以前的表記錄的話,有可能要出現重複資料,可以通過以下方式解決
首先,刪除使用者(本人用的test):DROP USER test CASCADE
其次,建立使用者(test)
create user test identified by test
default tablespace test_data
temporary tablespace test_temp
quota unlimited on test_data
account unlock;
然後,給建立使用者授權 GRANT CONNECT,DBA, RESOURCE TO test;
最後,執行匯入資料命令。