有没有办法使用 SQL 获取有关服务器的信息

2021-09-27 00:00:00 sql oracle windows-server

有没有办法使用 SQL 获取有关服务器的信息?它是一个使用 Windows 服务器的 Oracle 数据库.我搜索了谷歌,我发现的只是 @@version 这不起作用.谢谢你的帮助.

Is there a way to get information about a server using SQL? It is an Oracle database using a windows server. I searched google and all I found was @@version which does not work. Thanks for your help.

推荐答案

这里有一个很好的主要信息检索例程列表.确保这是获取服务器信息的最佳方式:

Here is a good list of the main informations retrieve routines. Be sure this is the best way to obtain Server infos:

甲骨文

版本:PL/SQL、TNS 版本与 Oracle 一起使用.

Version: PL/SQL, TNS versions using with Oracle.

SELECT * FROM v$version;
-- Which version of oracle you are running.
SELECT * FROM v$version WHERE banner LIKE 'Oracle%';
-- Or, in more readable way.
SELECT * FROM product_component_version;

Instance:显示当前实例的状态.

Instance: Displays the state of the current instance.

SELECT * FROM v$instance;
-- About license limits of the current instance.
SELECT * FROM v$license;

数据库:数据库名称.

SELECT * FROM GLOBAL_NAME
--Db IP Address.
SELECT UTL_INADDR.get_host_address FROM dual
--Db Host Name.
SELECT UTL_INADDR.GET_HOST_NAME('above ip address') FROM dual

客户端:客户端 IP 地址.

Client: Client IP Address.

SELECT SYS_CONTEXT('USERENV','IP_ADDRESS') FROM dual
--Db Host Name
SELECT SYS_CONTEXT('USERENV','TERMINAL') FROM dual
--Db Host Name with domain.
SELECT SYS_CONTEXT('USERENV','HOST') FROM dual
--Current Client session details who using DB.
SELECT * FROM v$session WHERE username = 'User/Schema name'
--To which DB user connected to.
SELECT SUBSTR(GLOBAL_NAME, 1, INSTR(GLOBAL_NAME,'.')-1) FROM GLOBAL_NAME

SQL Server

版本:您正在运行的 Sql 服务器版本.

Version: Which versions of Sql sever you are running.

SELECT @@VERSION
SELECT SERVERPROPERTY('productversion'), SERVERPROPERTY ('edition')
-- SERVERPROPERTY Returns property information about the server instance.

客户端:客户端详细信息(IP 地址、机器名称、使用的实例).

Client: Client details (IP Address, Machine Name, Instance using).

SELECT con.client_net_address as IPAddress,
         sess.host_name as MachineName, sess.program_name as ApplicationName,
         login_name as LoginName
FROM sys.dm_exec_connections con
inner join sys.dm_exec_sessions sess
on con.session_ID=sess.session_ID
WHERE con.session_ID = @@SPID

有关详细信息:http://msdn.microsoft.com/en-我们/图书馆/ms174396.aspx

相关文章