exp本地匯出與imp本地匯入
exp命令:
1 exp username/psw@TEST file=d:test.dmp full=y
2 exp username/psw@TEST file=d:test.dmp owner=(ly)
3 exp username/psw@TEST file= d:test.dmp tables=(grid1,grid2)
1其中一是將Test(與某一資料庫對應的oracle服務名)資料庫進行整體匯出
2將屬於使用者ly的所有表匯出
3將表grid1,與grid2匯出
d:test.dmp是匯出的檔案地址
imp命令:
1 imp system/psw@TEST file=d:test.dmp
2 imp system/psw@TEST full=y file=d:test.dmp ignore=y
3 imp system/psw@TEST file=d:test.dmp tables=(grid1)ignore=y表示如果被匯入的資料庫中某個表已經存在就忽略不匯入那個表
3表示只匯入grid1這個表
在匯入匯出前要先測試下對應的資料庫是否是通的:tnsping test來測試,同樣test是服務名
所有命令可在cmd下執行
用exp/imp遠程操作資料庫
對ORACLE資料庫進行遠程操作,假設資料庫在192.168.1.110上,具體方法如下:
一、在用戶端建立和服務端對應的服務名
方法1:
修改tnsnames.ora檔案
加入遠程伺服器的命名:
Sql代碼
TEST_ORCL =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.110)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = orcl)
)
)
方法2:
在oracle用戶端,開啟net manager。
建立一個服務命名TEST_ORCL,主機IP為:192.168.1.110,服務名orcl,連接埠1521
二、測試遠程伺服器是否暢通
進入到cmd後,執行命令:tnsping TEST_ORCL。
三、遠程操作資料庫
匯出:
Sql代碼
1:exp username/password@TEST_ORCL file=bak_filepath
2:exp username/password@TEST_ORCL full=y file=bak_filepath
username 使用者名稱,password 密碼,TEST_ORCL 客服端服務名,bak_filepath 備份檔案存放的路徑
匯入:
Sql代碼
1:imp username/password@TEST_ORCL file=bak_filepath full=y
2:imp
username/password@TEST_ORCL/database_name file=bak_filepath full=y
3:imp username/password@TEST_ORCL file=bak_filepath fromuser=fromadmin touser=toadmin
username 使用者名稱,password 密碼,TEST_ORCL 客服端服務名,bak_filepath 備份檔案存放的路徑
fromadmin 備份資料的使用者名稱,toadmin 還原資料庫的使用者名稱。database_name 還原到那個資料庫上
full=y 將資料庫整體匯出,包括表結構等。
IMP-00003: 遇到 ORACLE 錯誤 20001
今天使用imp匯入備份資料的時候出現問題
IMP-00003: 遇到 ORACLE 錯誤 20001
ORA-20001: Invalid or inconsistent input values
ORA-06512: at "SYS.DBMS_STATS", line 4194
ORA-06512: at line 1
GOOGLE了一下,是版本差異引起的問題
再去查看exp和imp的版本,果然是有差異,exp的是10.2.0版本,imp的是10.1.0的版本,
oracle是向下相容,低版本匯出的資料能匯入高版本,高版本匯出的資料無法匯入低版本
查看oracle版本
用戶端:
sqlplus /nolog->可以看到用戶端版本
伺服器:
串連之後SQL> select * from v$version;—>可以查看伺服器的版本
但是又不想重新安裝用戶端
於是又搜了搜解決方案
有網友提出解決方案
加了statistics=none
imp user/user file=file.dmp full=y statistics=none
解決參數說明exp userid=user_name/user_pwd@net_service_name owner=user_name file=exp_user_name.dmp log=exp_user_name.log buffer=67108864 statistics=none grants=n
consistent=ybuffer緩衝區大小,64M,再往上也沒有明顯的效能提升
statistics:表示不匯出分析資料
grants:相關對象的授權
consistent:確保在imp的時候,不會出現fk不能enable的情況
exp help=y可以查看所有選項和說明,imp也一樣
轉載請標明出處 http://blog.csdn.net/shimiso
技術交流群:173711587