gpt4 book ai didi

sql - 无法使用 SID 连接到 SQL*Plus

转载 作者:行者123 更新时间:2023-12-02 03:31:20 25 4
gpt4 key购买 nike

我执行了以下查询来查找我作为系统连接的数据库的 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 的同时,如何以系统身份连接到数据库?

最佳答案

你说使用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>

关于sql - 无法使用 SID 连接到 SQL*Plus,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51759133/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com