[20180208]ezconnect語法.txt

lfree發表於2018-02-08

[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

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/267265/viewspace-2150938/,如需轉載,請註明出處,否則將追究法律責任。