DBA的日常功能SQL之一,绝对原创。
--查看系统中连接数的分布情况
select s.INST_ID,
sum(count(1)) over(partition by s.INST_ID) sum_inst,
s.MACHINE,
sum(count(1)) over(partition by s.INST_ID,S.MACHINE) sum_MACHINE,
s.TERMINAL,
sum(count(1)) over(partition by s.INST_ID,S.MACHINE,S.TERMINAL) sum_TERMINAL,
s.PROGRAM,
sum(count(1)) over(partition by s.INST_ID,S.MACHINE,S.TERMINAL,S.PROGRAM) sum_PROGRAM,
s.MODULE,
sum(count(1)) over(partition by s.INST_ID,S.MACHINE,S.TERMINAL,S.PROGRAM,S.MODULE) sum_MODULE,
count(1)
from gv$session s
where 1=1
--and s.INST_ID=1
group by s.INST_ID,
s.MACHINE,
s.PROGRAM,
s.TERMINAL,
s.MODULE
order by s.INST_ID,
s.MACHINE,
s.PROGRAM,
s.TERMINAL,
s.MODULE
;