tnsnames.ora配置注意(连接新的数据库)

时间:2021-04-08 07:45:49
文件地址D:\app\think\product\11.2.0\instantclient_11_2\network\admin\tnsnames.ora
# tnsnames.ora Network Configuration File: D:\app\think\product\11.2.0\client_1\NETWORK\ADMIN\tnsnames.ora# Generated by Oracle configuration tools.

SMSPLATFORM
=
(DESCRIPTION
=
(ADDRESS_LIST
=
(ADDRESS
= (PROTOCOL = TCP)(HOST = 192.168.1.250)(PORT = 1521))
)
(CONNECT_DATA
=
(SERVICE_NAME
= smsplatform)
)
)

WX_HOFFICE
=
(DESCRIPTION
=
(ADDRESS_LIST
=
(ADDRESS
= (PROTOCOL = TCP)(HOST = 192.168.1.250)(PORT = 1521))
)
(CONNECT_DATA
=
(SERVICE_NAME
= wx_hoffice)
)
)

WXPT
=
(DESCRIPTION
=
(ADDRESS_LIST
=
(ADDRESS
= (PROTOCOL = TCP)(HOST = 192.168.1.250)(PORT = 1521))
)
(CONNECT_DATA
=
(SERVICE_NAME
= wxpt)
)
)

如上的tnsnames.ora配置信息显示有三个数据库连接。

 需要注意的情况:
(1)如果tnsnames中的service_name配置错误,配置成了instance_name了,这个时候会发生tnsping能通,但是 sqlplus连接不上的奇怪情况。报错ORA-12514: TNS:listener could not resolve SERVICE_NAME given in connect descriptor。这个时候查错的时候,需要检查对应的service_name。

(2)有空格也会出错,需要删除空格

tnsnames.ora配置注意(连接新的数据库)

如:

空格dev_db =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 172.168.10.5)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SID = ora10)
    )
  )