日期:2014-05-16  浏览次数:20560 次

利用Instant Client ,不安装oracle客户端使用sqlplus连接远程数据库的步骤
利用Instant Client ,不安装oracle客户端使用sqlplus连接远程数据库的步骤

从oracle公司站点
http://www.oracle.com/technology/so...cs/winsoft.html
下载
Instant Client Package - Basic: All files required to run OCI, OCCI, and JDBC-OCI applications
instantclient-basic-win32-10.1.0.4-20050513.zip (31,436,437 bytes)

*Instant Client Package - SQL*Plus: Additional libraries and executable for running SQL*Plus with Instant Client instantclient-sqlplus-win32-10.1.0.4-20050513.zip (267,941 bytes)
然后释放到c:\
然后从一台安装了oem的机器上复制
%ORACLE_HOME\network\admin\tnsnames.ora
到C:\instantclient10_1
这样
C:\instantclient10_1将有下列文件
2005-08-05 12:36 <DIR> .
2005-08-05 12:36 <DIR> ..
2005-02-10 10:38 1,474,666 classes12.jar
2003-10-09 01:40 1,353 glogin.sql
2005-03-07 20:35 188,416 oci.dll
2005-02-10 10:35 61,712 ocijdbc10.dll
2005-08-04 11:10 49,152 ociuldr.exe
2005-03-07 19:45 274,432 ociw32.dll
2005-02-10 10:38 1,410,632 ojdbc14.jar
2005-03-04 05:02 995,600 orannzsbb10.dll
2005-03-07 20:37 1,065,436 oraocci10.dll
2005-03-07 20:36 82,325,504 oraociei10.dll
2004-12-14 20:45 22,945 README_IC.htm
2005-08-05 12:37 1,474 sqlnet.log
2002-01-08 13:11 265 sqlnet.ora
2005-02-17 21:10 684,032 sqlplus.exe
2005-07-26 12:50 1,366 tnsnames.ora
2005-08-05 12:37 917 uldrdata.txt
2005-03-07 20:37 <DIR> vc6
2005-03-07 20:37 <DIR> vc7
2005-03-07 20:37 <DIR> vc71
然后按照README_IC.htm的提示,设置环境变量
PATH为原来的PATH;C:\instantclient10_1,
SQLPATH,LOCAL,TNS_ADMIN为C:\instantclient10_1

然后运行cmd
c:>sqlplus /nolog
conn tom/tom@jia
可以发现已经能连接远程服务器了

我发现一个奇特的现象

oracle服务器为10.1.0.4的jia可以用
conn tom/tom@//10.6.99.120:1521/jia连接
而oracle服务器为9.2.0.6的075不可以用
conn tom/tom@//10.6.99.75:1521/epras连接
--------------------------------
C:\instantclient10_1>sqlplus /nolog

SQL*Plus: Release 10.1.0.4.0 - Production on Fri Aug 5 12:32:54 2005

Copyright (c) 1982, 2005, Oracle. All rights reserved.

SQL> conn tom/tom@jia
????
SQL> conn tom/tom@jia
????
SQL> select cout(*) from tab;
select cout(*) from tab
*
? 1 ?????:
ORA-00936: ?????


SQL> select count(*) from tab;

COUNT(*)
----------
54

SQL> conn tom/tom@//10.6.99.120:1521/jia
????
SQL> conn tom/tom@//10.6.99.75:1521/epras
ERROR:
ORA-12514: TNS:listener does not currently know of service requested in connect
descriptor


??: ?????? ORACLE?
SQL>
SQL> exit

C:\instantclient10_1>ociuldr user=tom/tom@jia query="select * from tab"
3100 bytes allocated for column TNAME (1)
800 bytes allocated for column TABTYPE (2)
4100 bytes allocated for column CLUSTERID (3)

0 rows exported at 2005-08-05 12:36:08
54 rows exported at 2005-08-05 12:36:08

C:\instantclient10_1>ociuldr user=tom/tom@//10.6.99.120:1521/jia query="select *
from tab"
3100 bytes allocated for column TNAME (1)
800 bytes allocated for column TABTYPE (2)
4100 bytes allocated for column CLUSTERID (3)

0 rows exported at 2005-08-05 12:36:41
54 rows exported at 2005-08-05 12:36:41

C:\instantclient10_1>ociuldr user=tom/tom@075 query="select * from tab"
3100 bytes allocated for column TNAME (1)
800 bytes allocated for column TABTYPE (2)
4100 bytes allocated for column CLUSTERID (3)

0 rows exported at 2005-08-05 12:37:02
57 rows exported at 2005-08-05 12:37:02

C:\insta