我需要查看SQL和Oracle中的活动连接数量,按程序分组。
To SQL我做了这个查询并且工作正常:
SELECT
DB_NAME(dbid) as DBName,
COUNT(dbid) as NumberOfConnections,
loginame as LoginName,
sys.sysprocesses.hostprocess
FROM
sys.sysprocesses
WHERE
dbid > 0
GROUP BY
dbid, loginame, hostprocess;
我想做一个在Oracle中返回相同结果的查询。 我尝试过在StackOverflow上找到的一些查询,但没有帮助我。
答案 0 :(得分:3)
要获取程序聚合的活动会话数,您可以尝试:
posts[1].status
在同一视图中,您可以找到更多有关sid,用户,客户端等信息; here你会发现更多信息。
只是为了完整起见,您必须在RAC环境中考虑select COUNT(*), PROGRAM
from v$session
where status = 'ACTIVE'
GROUP BY PROGRAM
答案 1 :(得分:1)
select status, count(*) as connections from V$SESSION group by status;
如果您需要查看username
所记录的用户,请使用此
select username,status, count(*) as connections from V$SESSION where username is not null group by status,username;
从我的数据库输出
+----------+---------------+
| STATUS | CONNECTIONS |
+----------+---------------+
| ACTIVE | 104 |
+----------+---------------+
| INACTIVE | 284 |
+----------+---------------+
此状态为ACTIVE
表示the number of session currently executing SQL
V$SESSION这里可以更多地了解它。