[20150924]tnsnames.ora是否可以带斜线.txt
--10g开始oracle支持ezconnect简单连接方式建立与数据库的连接。
d:\tools\sqltemp>sqlplus scott/xxxxxx@192.168.100.40:1521/test.com
SQL*Plus: Release 12.1.0.1.0 Production on Thu Sep 24 08:32:43 2015
Copyright (c) 1982, 2013, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SCOTT@192.168.100.40:1521/test.com> select utl_inaddr.get_host_address from dual;
GET_HOST_ADDRESS
------------------
192.168.100.40
--如果在本机的tnsnames.ora也配置一样的连接串,会出现什么情况呢?在本机的配置文件加入:
192.168.100.40/test =
(DESCRIPTION =
(SDU=32768)
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.100.89)(PORT = 1521))
)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = test)
)
)
d:\tools\sqltemp>sqlplus scott/xxxxxx@192.168.100.40/test.com
SQL*Plus: Release 12.1.0.1.0 Production on Thu Sep 24 08:50:31 2015
Copyright (c) 1982, 2013, Oracle. All rights reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SCOTT@192.168.100.40/test.com> select utl_inaddr.get_host_address c20 from dual;
C20
--------------------
192.168.100.89
--很明显这个时候使用的是tnsnames.ora里面的配置:
--在本机的配置文件修改如下:
192.168.100.40:1521/test.com =
(DESCRIPTION =
(SDU=32768)
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.100.89)(PORT = 1521))
)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = test)
)
)
d:\tools\sqltemp>sqlplus scott/xxxxxx@192.168.100.40:1521/test.com
SQL*Plus: Release 12.1.0.1.0 Production on Thu Sep 24 08:51:14 2015
Copyright (c) 1982, 2013, Oracle. All rights reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SCOTT@192.168.100.40:1521/test.com> select utl_inaddr.get_host_address c20 from dual;
C20
--------------------
192.168.100.89
--很明显依旧使用的是tnsnames.ora配置,并且里面还可以包含冒号。
--再本机的配置文件修改如下:
192.168.100.40:1521/test.com,192.168.100.40/test.com =
(DESCRIPTION =
(SDU=32768)
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.100.89)(PORT = 1521))
)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = test)
)
)
d:\tools\sqltemp>sqlplus scott/xxxxxx@192.168.100.40:1521/test.com
SQL*Plus: Release 12.1.0.1.0 Production on Thu Sep 24 08:51:56 2015
Copyright (c) 1982, 2013, Oracle. All rights reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SCOTT@192.168.100.40:1521/test.com> select utl_inaddr.get_host_address c20 from dual;
C20
--------------------
192.168.100.89
SCOTT@192.168.100.40:1521/test.com> connect scott/xxxxxx@192.168.100.40/test.com
Connected.
SCOTT@192.168.100.40/test.com> select utl_inaddr.get_host_address c20 from dual;
C20
--------------------
192.168.100.89
--当然最好不要这样配置,容易混淆。这样的测试仅仅是为了玩^_^。
--关于tnsnames.ora还可以参考我以前写的:
[20150409]tnsnames.ora与IFILE.txt http://blog.itpub.net/267265/viewspace-1561107/
[20141229]配置tnsnames.ora使用rsp文件 http://blog.itpub.net/267265/viewspace-1383445/
[20140226]tnsnames.ora别名之间使用逗号 http://blog.itpub.net/267265/viewspace-1090384/
[20130528]tnsnames.ora的格式问题.txt http://blog.itpub.net/267265/viewspace-762224/
[20111220]tnsnames.ora的定位.txt http://blog.itpub.net/267265/viewspace-713629/