有没有办法使用 SQL 获取有关服务器的信息?它是一个使用 Windows 服务器的 Oracle 数据库。我搜索了谷歌,我发现的只是@@version
哪个不起作用。谢谢你的帮助。
问问题
14908 次
2 回答
11
这是主要信息检索例程的一个很好的列表。确保这是获取服务器信息的最佳方式:
甲骨文
版本:PL/SQL,TNS 版本与 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:显示当前实例的状态。
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 地址。
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 服务器
版本:您正在运行哪些版本的 Sql 服务器。
SELECT @@VERSION
SELECT SERVERPROPERTY('productversion'), SERVERPROPERTY ('edition')
-- SERVERPROPERTY Returns property information about the server instance.
客户端:客户端详细信息(IP 地址、机器名称、使用的实例)。
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
于 2013-05-15T13:19:39.337 回答
1
I really don't know why you are doing this since there are several better ways to get more info of your database, nevertheless:
Try this:
select * from v$version;
If it returns result, it is Oracle.
If not try this:
SELECT @@VERSION
If it returns result it is SQL Server.
于 2013-05-15T13:10:27.117 回答