结果集耗尽时,检查是否关闭结果集时常用sql

--打开的游标统计
select sum(a.value) total_cur,
avg(a.value) avg_cur,
max(a.value) max_cur,
s.username,
s.machine
from v$sesstat a, v$statname b, v$session s
where a.statistic# = b.statistic#
and s.sid = a.sid
and b.name = 'opened cursors current'
and machine like '%yaohuiqin%'
group by s.username, s.machine
order by 1 desc;

--根据用户名、sid统计游标
select o.sid, osuser, machine, count(*) num_curs
from v$open_cursor o, v$session s
where user_name = 'BXCWGZ' and o.sid=s.sid
and machine like '%yaohuiqin%'
and cursor_type in ('OPEN','OPEN-RECURSIVE')
group by o.sid, osuser, machine
order by num_curs desc;

--查询指定用户下游标及对应sql
select q.sql_text,cursor_type,o.sid
from v$open_cursor o, v$sql q
where q.sql_id=o.sql_id and o.sid in('209','7','221','366','63','92','465','364','163','109','135')
and cursor_type in ('OPEN','OPEN-RECURSIVE')
and q.sql_text not like '%$%'
and q.sql_text like '%LCurrency%'
order by o.sid,q.LAST_LOAD_TIME desc


Select FCurCode From A2019297LCurrency where FIsBase=1

Select FCurCode From A2019441LCurrency where FIsBase=1


select q.sql_text,cursor_type,o.sid
from v$open_cursor o, v$sql q
where q.sql_id=o.sql_id and o.sid ='309'
and cursor_type in ('OPEN','OPEN-RECURSIVE')
and q.sql_text not like '%$%'
order by o.sid,q.LAST_LOAD_TIME desc

--同上,分组显示
select q.sql_text, count(1)
from v$open_cursor o, v$sql q
where q.sql_id=o.sql_id and o.sid = 286
group by q.sql_text
order by count(1) desc

select cursor_type,count(*) from v$open_cursor where sid = 286 group by cursor_type


select cursor_type,count(*) from v$open_cursor where sid = 286 group by cursor_type


select * from v$open_cursor where sid = 465 and cursor_type in ('OPEN','OPEN-RECURSIVE')

转载于:https://www.cnblogs.com/yaohuiqin/p/10636660.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值