Oracle數據導入導出imp/exp
功能:Oracle數據導入導出imp/exp相當於oracle數據還原與備份。
說明:大多情況都可以用Oracle數據導入導出完成數據的備份和還原(不會造成數據的丟失)。
一、數據導出
-
將數據庫TEST完全導出,用戶名system 密碼manager 導出到D:\export.dmp中(我這里使用這種方式)
exp system/manager@TEST file=d:\export.dmp full=y
2、將數據庫中system用戶與sys用戶的表導出
exp system/manager@TEST file=d:\export.dmp owner=(system,sys)
3、 將數據庫中的表table1 、table2導出
exp system/manager@TEST file=d:\export.dmp tables=(table1,table2)
4、 將數據庫中的表table1中的字段filed1以"00"打頭的數據導出
exp system/manager@TEST file=d:\export.dmp tables=(table1) query=\" where filed1 like '00%'\"
數據壓縮: 上面是常用的導出,用winzip把dmp文件可以很好的壓縮。不過在上面命令后面 加上 compress=y 就可以了
二、數據導入
1 、將D:\export.dmp 中的數據導入 TEST數據庫中。
imp system/manager@TEST file=d:\export.dmp
上面可能有點問題,因為有的表已經存在,然后它就報錯,對該表就不進行導入。在后面加上 ignore=y 就可以了。
2、 將d:\export.dmp中的表table1 導入
imp system/manager@TEST file=d:\export.dmp tables=(table1)
注意:
你要有足夠的權限,權限不夠它會提示你。
數據庫時可以連上的。可以用tnsping TEST 來獲得數據庫TEST能否連上。
三、其他
數據導出:
exp hkb/hkb@boss_14 full=y file=c:\orabackup\hkbfull.dmp log=c:\orabackup\hkbfull.log;
導出注意事項:導出的是當前用戶的的數據,當前用戶如果有DBA的權限,則導出所有數據!
同名用戶之間的數據導入:
imp hkb/hkb@xe file=c:\orabackup\hkbfull.dmp log=c:\orabackup\hkbimp.log full=y
不同名之間的數據導入:
imp system/test@xe fromuser=hkb touser=hkb_new file=c:\orabackup\hkbfull.dmp log=c:\orabackup\hkbimp.log;
如果導入時版本不一致,提示(IMP-00010:不是有效的導出文件,頭部驗證失敗)請手動修改版本,請使用如下方法調整版本: