ITPub博客

首页 > Linux操作系统 > Linux操作系统 > 不安装oracle客户端使用sqlplus

不安装oracle客户端使用sqlplus

原创 Linux操作系统 作者:scott8486 时间:2012-02-13 15:53:44 0 删除 编辑

一、软件下载及环境配置
1.软件下载
http://www.oracle.com/technology/software/tech/oci/instantclient/htdocs/winsoft.html下载如下三个包:
instantclient-basic-win32-10.2.0.4.zip
instantclient-jdbc-win32-10.2.0.4.zip
instantclient-sqlplus-win32-10.2.0.4.zip
将这三个包分别解压,然后内容放到C:\instantclient_10_2下

然后从一台安装了oem的机器上复制%ORACLE_HOME\network\admin\tnsnames.ora也放到C:\instantclient_10_2中

http://www.anysql.net/software/ociuldr.zip下载coiuldr.zip,解压后里面有windowslinux
solaris三个版本,将ociuldr.exe 复制到C:\instantclient_10_2,其中ociuldr.exe 是一个文本导出工具,具体参数可以参考
http://www.anysql.net/ociuldr.html介绍

2.环境变量的设置
在PATH中增加;C:\instantclient_10_2;
新建SQLPATH,LOCAL,TNS_ADMIN,LD_LIBRARY_PATH四个环境变量名,变量值均为C:\instantclient_10_2;
如果查询结果为乱码,设置set NLS_LANG=XXXX(例如SIMPLIFIED CHINESE_CHINA.ZHS16GBK)

3. 如果开发JAVA应用程序,还要配置一些环境变量,
例如CLASSPATH,JAVA_HOME等等. CLASSES12.jar 文件是
必须的,其他的根据需要添加.

4. 如果启动SQLPLUS时出现下面的错误:
ORA-12545: Connect failed because target host or object does not exist
试着把tnsnames.ora 中的host 改成IP地址。

二、运行
运行cmd
c:>sqlplus /nolog
SQL:>conn
system/oracle@orc10g
这样就已经能连接远程服务器

也可以这么连接:
conn
system/oracle@//192.168.1.179:1521/orc10g连接
C:\instantclient_10_2>sqlplus /nolog
SQL*Plus: Release 10.2.0.4.0 - Production on Thu Nov 27 14:45:51 2008Copyright (c) 1982, 2007, Oracle. All Rights Reserved.
SQL> conn
system/oracle@//192.168.1.179:1521/orc10g
Connected.
     
下面看一下ociuldr应用的方法:
C:\instantclient_10_2>ociuldr
user=system/oracle@orc10gquery="select username from dba_users" file=dba_users.txt
1550 bytes allocated for column USERNAME (1)
0 rows exported at 2008-11-27 14:49:44
29 rows exported at 2008-11-27 14:49:44
output file dba_users.txt closed at 29 rows.
这样查询结果就输出到dba_user.txt文件里面了。

配置tnsnames.ora和sqlnet.ora.。如果本机找不到示例文件,就从其他装有oracle的机器上拷一个。
我拷贝了10g和9i版本下各一份:
10g下tnsnames.ora内容
# tnsnames.ora Network Configuration File: C:\oracle\product\10.1.0\Db_1\network\admin\tnsnames.ora
# Generated by Oracle configuration tools.

ORC10G =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = database007)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orc10g)
)
)

EXTPROC_CONNECTION_DATA =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC))
)
(CONNECT_DATA =
(SID = PLSExtProc)
(PRESENTATION = RO)
)
)


10g下sqlnet.ora的内容
# sqlnet.ora Network Configuration File: C:\oracle\product\10.1.0\Db_1\network\admin\sqlnet.ora
# Generated by Oracle configuration tools.

SQLNET.AUTHENTICATION_SERVICES= (NTS)

NAMES.DIRECTORY_PATH= (TNSNAMES, EZCONNECT)


9i版本下的内容
# TNSNAMES.ORA Network Configuration File: d:\oracle\ora92\network\admin\tnsnames.ora
# Generated by Oracle configuration tools.

ORA9I_192.168.2.206 =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.2.206)(PORT = 1521))
)
(CONNECT_DATA =
(SID = ora9i)
(SERVER = DEDICATED)
)
)

WS_192.168.1.101 =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.101)(PORT = 1521))
)
(CONNECT_DATA =
(SID = ws)
(SERVER = DEDICATED)
)
)

ORA9I_192.168.2.50 =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.2.50)(PORT = 1521))
)
(CONNECT_DATA =
(SID = ora9i)
(SERVER = DEDICATED)
)
)


9下sqlnet.ora的内容
# SQLNET.ORA Network Configuration File: d:\oracle\ora92\network\admin\sqlnet.ora
# Generated by Oracle configuration tools.

SQLNET.AUTHENTICATION_SERVICES= (NTS)

NAMES.DIRECTORY_PATH= (TNSNAMES, ONAMES, HOSTNAME)

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/25574072/viewspace-716159/,如需转载,请注明出处,否则将追究法律责任。

上一篇: PXE安装linux系统
下一篇: mount nfs
请登录后发表评论 登录
全部评论

注册时间:2011-03-28

  • 博文量
    42
  • 访问量
    136061