使用plsql访问远程数据库

在自己的Oracle安装目录找到以下文件:tnsnames.ora

例如:

D:\app\Administrator\product\11.1.0\db_1\NETWORK\ADMIN\tnsnames.ora

打开文件添加以下内容:

非集群,数据库在一台服务器上:

名称 =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = ip地址)(PORT = 端口号))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = 数据库实例)
    )
  )

//例如下面这个
KZJN =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 10.1.162.146)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = orcl)
    )
  )

集群,数据库在多台服务器上:

名称 =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = ip地址1)(PORT = 对应端口号))
    (ADDRESS = (PROTOCOL = TCP)(HOST = ip地址1)(PORT = 对应端口号))
    (LOAD_BALANCE = yes)
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SID = 数据库实例)
    )
  )
  
//例如下面这个
JQ =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 10.1.190.88)(PORT = 1521))
    (ADDRESS = (PROTOCOL = TCP)(HOST = 10.1.190.99)(PORT = 1521))
    (LOAD_BALANCE = yes)
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SID = tmis21)
    )
  )

保存修改后打开plsql,在数据库下拉列表中回多出新添加的内容,选择对应的下拉项,填写用户名密码即可。


使用plsql访问远程数据库_第1张图片
这里写图片描述

你可能感兴趣的:(使用plsql访问远程数据库)