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

Is there a way to get information about a server using SQL(有没有办法使用 SQL 获取有关服务器的信息)
本文介绍了有没有办法使用 SQL 获取有关服务器的信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法使用 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

这篇关于有没有办法使用 SQL 获取有关服务器的信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Execute complex raw SQL query in EF6(在EF6中执行复杂的原始SQL查询)
Hibernate reactive No Vert.x context active in aws rds(AWS RDS中的休眠反应性非Vert.x上下文处于活动状态)
Bulk insert with mysql2 and NodeJs throws 500(使用mysql2和NodeJS的大容量插入抛出500)
Flask + PyMySQL giving error no attribute #39;settimeout#39;(FlASK+PyMySQL给出错误,没有属性#39;setTimeout#39;)
auto_increment column for a group of rows?(一组行的AUTO_INCREMENT列?)
Sort by ID DESC(按ID代码排序)