PLsql连接到本地/远程Oracle数据库

Oracle数据库下载与安装:https://blog.csdn.net/With_Her/article/details/88194720

一、说明

网上看到很多博客让下载Instant Client,这个是oracle的轻量级客户端,如果你不想本地安装oracle,可以下载Instant Client来配置,我在这边文章就不多说了,网上也有许多。

本篇博客是基于oracle+plsql来进行安装,配置的,未单独安装Instant Client(其实安装了oracle,它的基目录下已经有了所需的配置文档)

下面就具体说一下

二、安装

主要有三步:

1.去oracle的基目录中,product\12.1.0\dbhome_1\NETWORK\ADMIN,找到下面这俩文件
PLsql连接到本地/远程Oracle数据库_第1张图片
一个是监听配置,一个是要连接的数据库信息
lister.ora:
 

# listener.ora Network Configuration File: E:\Oracle\Oracle12C\basic\product\12.1.0\dbhome_1\network\admin\listener.ora
# Generated by Oracle configuration tools.

SID_LIST_LISTENER =
(SID_LIST =
 (SID_DESC =
 (GLOBAL_DBNAME = orcl) #cdb db_name
 (SID_NAME = orcl)
 )
 (SID_DESC =
 (GLOBAL_DBNAME = orclpdb) #pdb db_name
 (SID_NAME = orcl)
 )
)


LISTENER =
(DESCRIPTION =
 (ADDRESS = (PROTOCOL = TCP)(HOST =localhost)(PORT = 1521))
 (CONNECT_DATA = (SERVICE_NAME = orcl))
)


tnsnames.ora:
 

# tnsnames.ora Network Configuration File: E:\Oracle\Oracle12C\basic\product\12.1.0\dbhome_1\network\admin\tnsnames.ora
# Generated by Oracle configuration tools.

LISTENER_ORCL =
  (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))


ORACLR_CONNECTION_DATA =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
    )
    (CONNECT_DATA =
      (SID = CLRExtProc)
      (PRESENTATION = RO)
    )
  )

ORCL =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = orcl)
    )
  )
#如果想要再添加其他数据库的连接信息,往下继续增量即可
数据库实例名 =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = ip地址)(PORT = 端口))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = 数据库实例名)
    )
  )



2.打开plsql,直接点取消进去,找到Configure-Connection,配置主目录名与OIC库,然后关闭plsql
PLsql连接到本地/远程Oracle数据库_第2张图片

3.新增两个环境变量

TNS_ADMIN
oracle下product\12.1.0\dbhome_1\NETWORK\ADMIN的地址

PLsql连接到本地/远程Oracle数据库_第3张图片

NLS_LANG
SIMPLIFIED CHINESE_CHINA.ZHS16GBK
(定义语言,地域以及字符集属性。对于非英语的字符集,NLS_LANG的设置就非常重要)
PLsql连接到本地/远程Oracle数据库_第4张图片

三,到此就ok了,启动plsql,
PLsql连接到本地/远程Oracle数据库_第5张图片
此时应该就可以连上了!
 

如果有什么问题,请留言交流!


参考:https://blog.csdn.net/zhige_j/article/details/80832654

你可能感兴趣的:(DataBase)