[20180208]ezconnect语法.txt

[20180208]ezconnect语法.txt

--昨天看书Oracle Database11g DBA Handbook.pdf,Using Easy Connect Naming P561.发现如下内容:

connect username/password@[//]host[:port][/service_name][/server][/instance_name]

Element            Description
//                 Optional. Specify // for a URL.
Host               Required. Specify the host name or the IP address.
Port               Optional. Specify the port or use the default (1521).
service_name       Optional. Specify the service name. The default value is the host name of the database server.
server             Optional. Also known as connect_type in OCI, specifies the type of service handler: dedicated, shared, or pooled.
instance_name      Optional. Corresponds to the INSTANCE_NAME initialization parameter.

For URL or JDBC connections, prefix the connect identifier with a double slash (//):
connect username/password@[//][host][:port][/service_name]

--//如果通过ezconnect连接数据库特定实例,可以这样:

sqlplus system/xxxxxxxxxxxx@192.168.aa.bb:1521/fyhis:dedicated/fyhis1

SYSTEM@192.168.aa.bb:1521/fyhis:dedicated/fyhis1> select INSTANCE_NUMBER,INSTANCE_NAME from v$instance ;
INSTANCE_NUMBER INSTANCE_NAME
--------------- ----------------
              1 fyhis1

sqlplus system/xxxxxxxxxxxx@192.168.aa.bb:1521/fyhis:dedicated/fyhis2

SYSTEM@192.168.aa.bb:1521/fyhis:dedicated/fyhis2> select INSTANCE_NUMBER,INSTANCE_NAME from v$instance ;
INSTANCE_NUMBER INSTANCE_NAME
--------------- ----------------
              2 fyhis2

--//这样可以连接不同实例.这样写也可以:
sqlplus system/xxxxxxxxxxxx@192.168.aa.bb:1521/fyhis:/fyhis1
sqlplus system/xxxxxxxxxxxx@192.168.aa.bb:1521/fyhis:/fyhis2
sqlplus system/xxxxxxxxxxxx@192.168.aa.bb:1521/fyhis/fyhis1
sqlplus system/xxxxxxxxxxxx@192.168.aa.bb:1521/fyhis/fyhis2

--//注文档有误,应该是这样,server前使用:.

connect username/password@[//]host[:port][/service_name][:server][/instance_name]
R:\>sqlplus system/xxxxxxxxxxxx@192.168.aa.bb:1521/fyhis/dedicated/fyhis2
SQL*Plus: Release 12.1.0.1.0 Production on Thu Feb 8 08:59:26 2018
Copyright (c) 1982, 2013, Oracle.  All rights reserved.
ERROR:
ORA-12521: TNS:listener does not currently know of instance requested in connect descriptor

请使用浏览器的分享功能分享到微信等