在http://icyheart.iteye.com/blog/424760中详细分析了exp/imp在本地数据库上的操作,其实exp/imp除了上述的功能外,还可以对远程数据库进行操作,具体方法如下:
一、修改tnsnames.ora文件
加入远程服务器的命名:
- 192.168.1.117 =
- (DESCRIPTION =
- (ADDRESS_LIST =
- (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.117)(PORT = 1521))
- )
- (CONNECT_DATA =
- (SERVICE_NAME = orcl)
- )
- )
192.168.1.117 =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.117)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = orcl)
)
)
二、测试远程服务器是否畅通
进入到cmd后,执行命令:tnsping 192.168.1.117,如果连接正常应返回下面的界面:
- C:\Documents and Settings\Administrator>tnsping 192.168.1.117
- TNS Ping Utility for 32-bit Windows: Version 10.2.0.1.0 - Production on 12-8月 -2009 09:06:53
- Copyright (c) 1997, 2005, Oracle. All rights reserved.
- 已使用的参数文件:
- e:\oracle\product\10.2.0\db_1\network\admin\sqlnet.ora
- 已使用 TNSNAMES 适配器来解析别名
- Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.117)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME =
- orcl)))
- OK (50 毫秒)
C:\Documents and Settings\Administrator>tnsping 192.168.1.117
TNS Ping Utility for 32-bit Windows: Version 10.2.0.1.0 - Production on 12-8月 -2009 09:06:53
Copyright (c) 1997, 2005, Oracle. All rights reserved.
已使用的参数文件:
e:\oracle\product\10.2.0\db_1\network\admin\sqlnet.ora
已使用 TNSNAMES 适配器来解析别名
Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.117)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME =
orcl)))
OK (50 毫秒)
三、远程操作数据库
导出:
- exp username/password@192.168.1.117 file=c:\本地存放数据库备份后的路径
exp username/password@192.168.1.117 file=c:\本地存放数据库备份后的路径
导入:
- imp username/password@192.168.1.117 file=要导入远程数据库的文件 full=y
imp username/password@192.168.1.117 file=要导入远程数据库的文件 full=y
好了,完成了!这样就不用再远程登陆服务器去操作了