【DBA 脚本】查询current open cursor的脚本

本文介绍了一个Oracle自定义视图user_cursors的创建过程,该视图用于统计每个会话的递归调用次数、累计打开游标数及当前打开游标数,帮助管理员监控数据库性能。
show parameter session_cached_cursor
drop view user_cursors;
create view user_cursors as
select
ss.username||'('||se.sid||') ' user_process, sum(decode(name,'recursive calls',value)) "Recursive Calls",
sum(decode(name,'opened cursors cumulative',value)) "Opened Cursors", sum(decode(name,'opened cursors current',value)) "Current Cursors"
        from v$session ss, v$sesstat se, v$statname sn
where  se.statistic# = sn.statistic#
                and (     name  like '%opened cursors current%'
                                OR name  like '%recursive calls%'
                                OR name  like '%opened cursors cumulative%')
                and  se.sid = ss.sid
                and     ss.username is not null
group by ss.username||'('||se.sid||') ';

ttitle 'Per Session Current Cursor Usage '
column USER_PROCESS format a25;
column "Recursive Calls" format 999,999,999;
column "Opened Cursors"  format 99,999;
column "Current Cursors"  format 99,999;

select * from user_cursors   
order by "Recursive Calls" desc;
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值