查詢方法:1、用“select count(*) from v$open_cursor”;2、用“SELECT A.USER_NAME,COUNT(*) FROM V$OPEN_CURSOR A GROUP BY A.USER_NAME”。
本教程操作環(huán)境:Windows7系統(tǒng)、Oracle 11g版、Dell G3電腦。
1、查看系統(tǒng)游標(biāo)數(shù)(最大游標(biāo)數(shù))
select value from v$parameter where name = 'open_cursors';show parameter open_cursors;
2、查看當(dāng)前打開的游標(biāo)數(shù)目
select count(*) from v$open_cursor;
3、查看游標(biāo)使用情況
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最大游標(biāo)數(shù)
根據(jù)游標(biāo)占用情況分析訪問數(shù)據(jù)庫的程序在資源釋放上是否正常,如果程序釋放資源沒有問題,則加大游標(biāo)數(shù)。
alter system set open_cursors=2000 scope=both;
5、各用戶的打開游標(biāo)總數(shù)
SELECT A.USER_NAME, COUNT(*) FROM V$OPEN_CURSOR A GROUP BY A.USER_NAME;
6、查找數(shù)據(jù)庫各用戶各個(gè)終端的緩存游標(biāo)數(shù)
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、查找數(shù)據(jù)庫各用戶各個(gè)終端的打開游標(biāo)數(shù)
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教程》