本教程操作环境:windows7系统、oracle 11g版、dell g3电脑。
1、查看系统游标数(最大游标数)
select value from v$parameter where name = 'open_cursors';show parameter open_cursors;
2、查看当前打开的游标数目
select count(*) from v$open_cursor;
3、查看游标使用情况
select o.sid, osuser, machine,o.sql_id,o.sql_text,o.cursor_type, count(*) num_curs from v$open_cursor o, v$session s where user_name = 'glogowner' and o.sid = s.sid group by o.sid, osuser, machine,o.sql_id,o.sql_text,o.cursor_type order by num_curs desc;
4、修改oracle最大游标数
根据游标占用情况分析访问数据库的程序在资源释放上是否正常,如果程序释放资源没有问题,则加大游标数。
alter system set open_cursors=2000 scope=both;
5、各用户的打开游标总数
select a.user_name, count(*) from v$open_cursor a group by a.user_name;
6、查找数据库各用户各个终端的缓存游标数
select aa.username, aa.machine, sum(aa.value) from (select a.value, s.machine, s.username from v$sesstat a, v$statname b, v$session s where a.statistic# = b.statistic# and s.sid = a.sid and b.name = 'session cursor cache count') aa group by aa.username, aa.machine order by aa.username, aa.machine;
7、查找数据库各用户各个终端的打开游标数
select aa.username, aa.machine, sum(aa.value) from (select a.value, s.machine, s.username 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') aa group by aa.username, aa.machine order by aa.username, aa.machine;
推荐教程:《oracle教程》
以上就是oracle怎么查询游标的详细内容。
