博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
通过Instant Client包来使用SQL*PLUS
阅读量:4700 次
发布时间:2019-06-09

本文共 4653 字,大约阅读时间需要 15 分钟。

1.首先下载两个程序包:

   Instant Client Package - Basic(或Instant Client Package - Basic Lite)包

   Instant Client Package - SQL*Plus包

   下载地址:

   

2.将Instant Client Package – Basic和Instant Client Package - SQL*Plus解压,

   例将其中的文件放在目录C:\Instantclient10_2

3.设置环境变量:

  1)在环境变量PATH中开头增加C:\Instantclient10_2;

  2)增加用户环境变量SQLPATH,值为C:\Instantclient10_2

  3)增加用户环境变量NLS_LANG,值为AMERICAN_AMERICA.UTF8(中文可能乱码,可改用AMERICAN_AMERICA.ZHS16GBK)

4.到此已经可以用SQL*Plus连接远程数据库,但书写方式必须如下例:

   Sqlplus 

   如果想要使用配置于TNSnames.ora中的连接字符串来连接,

   增加环境变量TNS_ADMIN,

   值为tnsnames.ora所在的目录,例: C:\Instantclient10_2\network\admin(建立

   C:\Instantclient10_2\network\admin目录,将TNSnames.ora放在此目录下),

   并编辑TNSnames.ora

如:

LORCL=

  (DESCRIPTION = 

    (ADDRESS_LIST = 

        (ADDRESS = 

          (PROTOCOL = TCP)

          (Host = 192.168.159.128)

          (Port = 1521)

        )

    )

    (CONNECT_DATA = (SID = LORCL)

    )

  )

   此时连接数据库,例:

   Sqlplus sys/sys@vmorcl as sysdba

   或sqlplus sys@vmorcl as sysdba

另:使用PL/SQL Developer的话,直接在preference中将oracle home 设置为C:\instantclient10_2,oci library

       设为C:\instantclient\oci.dll

------------------------------------------------------------设置结束----------------------------------------------------------------

---------------------------------------------------------------------------------------------------------------------------------------

 

附:

一个网友按照上面步骤做了之后说还是不可以用,报错,

Initialization error

Could not load “C:\Instantclient10_2\oci.dll”

 

OCIDLL forced to C:\Instantclient10_2\oci.dll

LoadLibrary(C:\Instantclient10_2\oci.dll) returned 0

 

折腾很久没找到原因,后来他告诉我说他的目录不是C:\Instantclient10_2,而是C:\Instantclient11_XX,无语..

把自己Developer的Oracle Home的目录改成一个不存在的目录,测试,果然出现他所说的错误,如下

通过Instant Client包来使用SQL*PLUS - Gabriel -    Gabriel 

 

而且登陆框是下面这个样子

通过Instant Client包来使用SQL*PLUS - Gabriel -    Gabriel

 

明显没有应用到那个InstantClient中的组件…

正常的时候应该像如下:

通过Instant Client包来使用SQL*PLUS - Gabriel -    Gabriel

 

 

---------------------------------------------------------------------------------------------------------------------------------------

附:SQL*Plus? User's Guide and Reference Release 10.2中详细说明

 for more information on the OCI Instant Client.

To , and  for more information about NLS settings.

. Both packages must be from the same version such as 10.2.0.1.

2.     Use rpm -i for the initial install of the RPM packages, or rpm -u to upgrade to a newer version of the packages.

3.     Configure SQL*Plus Instant Client. See .

. Both packages must be from the same version such as 10.2.0.1.

2.     Create a new directory, for example, /home/instantclient10_2 on UNIX or c:\instantclient10_2 on Windows.

3.     Unzip the two packages into the new directory.

4.     Configure SQL*Plus Instant Client. See .

 or  for a list of the files to copy.

4.     Configure SQL*Plus Instant Client. See .

 for more information.

For example:

NLS_LANG=AMERICAN_AMERICA.UTF8

export NLS_LANG

 for more information.

For example:

NLS_LANG=AMERICAN_AMERICA.UTF8

export NLS_LANG

 for more information. For example, to set NLS_LANG for a Japanese environment, create a user environment variable NLS_LANG set to JAPANESE_JAPAN.JA16EUC.

If you have installed the lightweight Instant Client, see  for information about supported NLS_LANG settings.

 for more information.

If you want to use Net Service Names configured in a local Oracle Net tnsnames.ora file, then set the environment variable TNS_ADMIN to the directory containing the tnsnames.ora file. For example, on UNIX, if your tnsnames.ora file is in /home/user1 and it defines the Net Service Name MYDB2:

TNS_ADMIN=/home/user1

export TNS_ADMIN

sqlplus hr@MYDB2

If TNS_ADMIN is not set, then an operating system dependent set of directories is examined to find tnsnames.ora. This search path includes looking in the directory specified by the ORACLE_HOME environment variable for network/admin/tnsnames.ora. This is the only reason to set the ORACLE_HOME environment variable for SQL*Plus Instant Client. If ORACLE_HOME is set when running Instant Client applications, it must be set to a directory that exists.

This example assumes the ORACLE_HOME environment variable is set, and the $ORACLE_HOME/network/admin/tnsnames.ora or %ORACLE_HOME%\network\admin\tnsnames.ora file defines the Net Service Name MYDB3:

sqlplus hr@MYDB3

The TWO_TASK (on UNIX) or LOCAL (on Windows) environment variable can be set to a connection identifier. This removes the need to explicitly enter the connection identifier whenever a connection is made in SQL*Plus or SQL*Plus Instant Client. This UNIX example connects to the database known as MYDB4:

TNS_ADMIN=/home/user1

export TNS_ADMIN

TWO_TASK=MYDB4

export TWO_TASK

sqlplus hr

On Windows, TNS_ADMIN and LOCAL may be set in the System Properties. See.

 for information on Oracle password files.

 for a list of the files you copied to the directory.

2.     Reset environment variables such as PATH, SQLPATH, LD_LIBRARY_PATH and TNS_ADMIN.

3.     Remove tnsnames.ora if necessary.

转载于:https://www.cnblogs.com/hllnj2008/p/4026187.html

你可能感兴趣的文章
解决在vue中,自用mask模态框出来后,下层的元素依旧可以滑动的问题
查看>>
修改node节点名称
查看>>
PAT(B) 1014 福尔摩斯的约会(Java)
查看>>
PAT甲级题解-1123. Is It a Complete AVL Tree (30)-AVL树+满二叉树
查看>>
项目开发总结报告(GB8567——88)
查看>>
SSH加固
查看>>
端口扫描base
查看>>
iOS IM开发的一些开源、框架和教程等资料
查看>>
FansUnion:共同写博客计划终究还是“流产”了
查看>>
python 二维字典
查看>>
pip 警告!The default format will switch to columns in the future
查看>>
Arrays类学习笔记
查看>>
实验吧之【天下武功唯快不破】
查看>>
2019-3-25多线程的同步与互斥(互斥锁、条件变量、读写锁、自旋锁、信号量)...
查看>>
win7-64 mysql的安装
查看>>
dcm4chee 修改默认(0002,0013) ImplementationVersionName
查看>>
maven3在eclipse3.4.2中创建java web项目
查看>>
发布时间 sql语句
查看>>
黑马程序员 ExecuteReader执行查询
查看>>
记一些从数学和程序设计中体会到的思想
查看>>