无法使用SID连接到SQL * Plus

时间:2018-08-09 04:59:10

标签: sql oracle

我执行以下查询以查找作为系统连接到的数据库的SID:

SQL> select sys_context('userenv','instance_name') from dual;

SYS_CONTEXT('USERENV','INSTANCE_NAME')
--------------------------------------------------------------
orcl

然后我尝试使用以下命令连接到系统:

C:\>sqlplus system/system@orcl

SQL*Plus: Release 12.2.0.1.0 Production on Wed Aug 8 23:53:02 2018

Copyright (c) 1982, 2016, Oracle.  All rights reserved.

ERROR:
ORA-12154: TNS:could not resolve the connect identifier specified

如何在指定SID的同时作为系统连接到数据库?

1 个答案:

答案 0 :(得分:1)

您说使用SID吗? 扩展连接字符串。方法如下:

我将使用TNSPING查找所需的信息:

M:\>tnsping orcl

TNS Ping Utility for 64-bit Windows: Version 11.2.0.1.0 - Production on 09-KOL-2018 07:13:18

Copyright (c) 1997, 2010, Oracle.  All rights reserved.

Used parameter files:
C:\0_Oracle_library\sqlnet.ora


Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION= (ADDRESS= (PROTOCOL=TCP) (HOST=db_kc11g) (PORT=1521)) (CONNECT_DATA= (SID=kc11g)))
OK (20 msec)

现在,连接:

M:\>sqlplus scott/tiger@(description=(address=(protocol=tcp)(host=db_kc11g)(port=1521))(connect_data=(sid=kc11g)))

SQL*Plus: Release 11.2.0.1.0 Production on ╚et Kol 9 07:14:05 2018

Copyright (c) 1982, 2010, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Data Mining and Real Application Testing options

SQL>

或更短:

M:\>sqlplus scott/tiger@db_kc11g:1521/kc11g

SQL*Plus: Release 11.2.0.1.0 Production on ╚et Kol 9 07:16:59 2018

Copyright (c) 1982, 2010, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Data Mining and Real Application Testing options

SQL>
相关问题