如何使用 SQL 语句获取 TCP PORT Oracle Server

How to get TCP PORT Oracle Server with SQL statment

在 Microsoft SQL 服务器中,我使用以下语句获取 TCP 端口:

select CONNECTIONPROPERTY('local_tcp_port') AS local_tcp_port;

1433

如何在 Oracle Server 中使用 SQL 语句获取 TCP PORT?

据我所知,你不能。没有 select 声明 你可以 运行 这会泄露该信息。

在命令提示符下,您可以尝试使用 tnsping,例如

c:\Temp>tnsping xe

TNS Ping Utility for 64-bit Windows: Version 11.2.0.2.0 - Production on 06-STU-2
020 21:38:22

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

Used parameter files:
C:\Users\lf\sqlnet.ora


Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = lflaptop)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = XE)))
OK (20 msec)                                                                             ----
                                                                                     here it is
c:\Temp>

或者,您可以询问您的 DBA,他们知道。