SID
----------
9
SQL> select sid from v$mystat where rownum =1;
SID
----------
9
Session Monitor:
SQL> select SID, USER_NAME,SQL_TEXT from v$open_cursor where sid=9;
SID USER_NAME SQL_TEXT
--- ---------- -----------------------------------------------------------
9 SCOTT select sid from v$mystat where rownum =1
SQL> SELECT SID, n.NAME para_name, s.VALUE used
2 FROM SYS.v_$statname n, SYS.v_$sesstat s
3 WHERE n.NAME IN ('opened cursors current', 'session cursor cache count')
4 AND s.statistic# = n.statistic#
5 AND SID = 9;
SID PARA_NAME USED
--- ------------------------------ ----------
9 opened cursors current 1
9 session cursor cache count 0
v$open_cursor dooes not show all open cursors. it shows more than that, the best option to find the
number of open cursors is from v$sysstat.
通过如上的执行结果可以知道,即使同一个游标被打开
3
次,
在
SESSION_CACHED_CURSOR
的数量仍然为
0
。
下面,将会在
Session Test
中关闭游标(通过执行一条其他的语句)。
Session Test:
SQL> select * from t where rownum!=7;
no rows selected
Session Monitor:
SQL> SELECT SID, n.NAME para_name, s.VALUE used
2 FROM SYS.v_$statname n, SYS.v_$sesstat s
3 WHERE n.NAME IN ('opened cursors current', 'session cursor cache count')
4 AND s.statistic# = n.statistic#
5 AND SID = 9;
SID PARA_NAME USED
--- ------------------------------ ----------
9 opened cursors current 1
9 session cursor cache count 1
SQL> select SID, USER_NAME,SQL_TEXT from v$open_cursor where sid=9;
SID USER_NAME SQL_TEXT