Oracle資料的匯出與匯入

2021-04-25 19:45:25 字數 2692 閱讀 2941

前序:關於oracle9i資料的匯出與匯入問題,折騰我好長時間了,尤其是匯入。今天在一位同事(zhangshukun)的指導下,算是終於成功了。

正文:oracle資料匯出:

如果是匯出本機的oracle資料庫:

exp pcisv62/11@orcl file="d:/pcisv62081226.dmp" full=y

(orcl為本地資料庫監聽)

如果是匯出伺服器端的oracle資料:

exp pcisv62/11@tnsname file="d:/pcisv62081226.dmp" full=y

(tnsname為corev6_dbserver,sid為corev6,主機為dbserver。)

注意:必須是 dba 才能執行完整資料庫或表空間匯出操作。

oracle資料匯入,分以下步驟:

1.先在oracle9i的enterprise manager console下,以sys/sys及sysdba身份登陸,在"儲存"-->"表空間"下建立表空間corev6,同時給其分配合適的空間。

2.在"安全性"-->"使用者"下建立使用者pcisv62,使使用者預設的表空間為corev6,同時在"角色"裡授予connect、dba、exp_full_database、imp_full_database、resource。

3.匯入.dmp檔案,開始-->執行cmd,匯入命令:

imp pcisv62/11@orcl file="d:/pcisv62081226.dmp" ignore=y

注意:如果備份的.dmp檔案是以使用者pcisv62匯出corev6空間的資料,那麼

1.新建的使用者最好是pcisv62,否則命令為:

imp pcisv62/11@orcl file="pcisv62081226.dmp" fromuser=pcisv62 touser=新建使用者 ignore=y

2.與新建使用者關聯的新建空間名必須為corev6,否則oracle報找不到corev6空間的錯誤。

資料成功匯入以後,下一步就是配置tomcat的server.xml檔案:

1.如果用到的是本機上的資料,本地資料來源裡的部分配置為: username="pcisv62" password="11"

url="jdbc:oracle:thin:@localhost:1521:orcl"

2.如果用到的是伺服器上的資料,則資料來源裡的部分配置為: username="pcisv62" password="11"

url="jdbc:oracle:thin:@dbserver:1521:corev6"(dbserver為伺服器的名字,corev6為伺服器上oracle的sid)

oracle的安裝目錄e:/oracle/ora92/network/admin下的tnsnames.ora:

本地配置:

orcl =

(description =

(address_list =

(address = (protocol = tcp)(host = 主機名)(port = 1521))

)(connect_data =

(server = dedicated)

(service_name = orcl)))

或伺服器配置:

corev6_dbserver =

(description =

(address_list =

(address = (protocol = tcp)(host = dbserver)(port = 1521))

)(connect_data =

(sid = corev6)

(server = dedicated)))

以下**:幾種匯入匯出的命令方法,以備以後查閱。

資料匯出:

exp qhmis/qhmis@qhmis file='d:/backup/qhmis/qhmis20060526.dmp' grants=y full=n

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 將資料庫中的表table1 、table2匯出

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

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

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

資料的匯入:

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

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

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

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

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

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

Oracle資料的匯入與匯出

一 expdp與impdp exp和imp是客戶端工具程式,它們既可以在客戶端使用,也可以在服務端使用。expdp和impdp是服務端的工具程式,他們只能在oracle服務端使用,不能在客戶端使用。imp只適用於exp匯出的檔案,不適用於expdp匯出檔案 impdp只適用於expdp匯出的檔案,而...

oracle 的匯入與匯出

在專案實施過程中,總會少不了與資料庫打交道,這是個人總結 刪除表空間 drop tablespace pt6 including contents drop tablespace mpm including contents drop tablespace sf including contents...

oracle資料匯入匯出

語法 imp userid password 資料庫全域性名 file dmp檔案的目錄 其它引數 獲取幫助,敲入 imp help y import常用的引數 1 file 指定匯入檔名 fromuser 允許匯入指定的使用者擁有的表 full full y時,匯入dmp檔案中所有的事物 igno...