1.下载Oracle Client Package .
从http://www.oracle.com/technology/software/tech/oci/instantclient/htdocs/winsoft.html下载
Instant Client Package – Basic包( 标注:All files required to run OCI, OCCI, and JDBC-OCI applications)这里下载的是Version 11.1.0.7
2.本地保存Oracle Client Package:
创建文件夹,比如oracle_client,将下载的文件加压缩到此文件夹里.(笔者目录: D:\oracle_client\instantclient_10_2)
3.在当前目录下,新建立两个文件,sqlnet.ora和tnsnames.ora然后再手动配置sqlnet.ora和tnsnames.ora
比如这里是:
sqlnet.ora文件内容:
SQLNET.AUTHENTICATION_SERVICES= (NTS)
NAMES.DIRECTORY_PATH= (TNSNAMES, EZCONNECT)
tnsnames.ora文件内容(斜体表示需要替换的内容):
orcl=
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.103)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = orcl)
)
)
4.配置环境变量
变量名: TNS_ADMIN
变量值: D:\instantclient-basic-win32-10.2.0.4\instantclient_10_2
否则出现:ORA-12154: TNS:could not resolve the connect identifier specified错误
D:\appUse\instantclient_10_2
如果之前安装了Oracle 又卸载,会遗留NLS_LANG=NA的键值.输入RegEdit打开注册表HKEY_LOCAL_MACHINE/SOFTWARE/ORACLE.在右面找到NLS_LANG=NA并删除掉
否则会报ORA-12705: Cannot access NLS data files or invalid 错误.
5.安装pl/sql软件(过程略)
6.配置pl/sql的Oracle连接参数:
选择pl/sql的工具/首选项(too/ preference/)里的连接,在右面设置Oracle主目录名(即安装目录)和OCI库.
Oracle主目录名: D:\instantclient-basic-win32-10.2.0.4\instantclient_10_2
OCI库:D:\instantclient-basic-win32-10.2.0.4\instantclient_10_2\oci.dll
7.登陆pl/sql测试成功
8:设置PL/SQL中文显示
环境变量,NLS_LANG :SIMPLIFIED CHINESE_CHINA.ZHS16GBK
如果想转换为UTF8字符集,可以赋予“NLS_LANG”为“AMERICAN_AMERICA.UTF8”
oracle查看数据库字符集
select * from nls_database_parameters,其来源于props$,是表示数据库的字符集。
客户端字符集环境select * from nls_instance_parameters,其来源于v$parameter,
表示客户端的字符集的设置,可能是参数文件,环境变量或者是注册表