最初由 rejoice999 发布
[B]如果想知道某个SESSION空闲了多长时间(和你说的最后ACTIVE时间是一个意思),必须给它设一个PROFILE,在PROFILE里限制它的空闲时间:idle_time ,可以设很大,因为我们并不是真正要限制它。
初始化参数RESOURCE_LIMIT 设成TRUE
column sid format 999 column last format a22 heading "Last non-idle time" column curr format a22 heading "Current time" column secs format 99999999.999 heading "idle-time |(seconds)" column mins format 999999.99999 heading "idle-time |(minutes)"
select sid, to_char((sysdate - (hsecs - value)/(100*60*60*24)), 'dd-mon-yy hh:mi:ss') last, to_char(sysdate, 'dd-mon-yy hh:mi:ss') curr, (hsecs - value)/(100) secs, (hsecs - value)/(100*60) mins from v$timer, v$sesstat where statistic# = (select statistic# from v$statname where name = 'process last non-idle time');
SID Last non-idle time Current time (seconds) (minutes) ---- ---------------------- ---------------------- ------------- ------------- 1 01-jul-94 12:21:52 06-nov-94 03:38:10 11070977.580 184516.29300 2 01-jul-94 12:21:52 06-nov-94 03:38:10 11070977.620 184516.29367 3 01-jul-94 12:21:52 06-nov-94 03:38:10 11070977.650 184516.29417 4 01-jul-94 12:21:52 06-nov-94 03:38:10 11070977.680 184516.29467 5 01-jul-94 12:21:52 06-nov-94 03:38:10 11070977.710 184516.29517 6 06-nov-94 03:38:07 06-nov-94 03:38:10 3.000 .05000 7 06-nov-94 01:06:27 06-nov-94 03:38:10 9102.970 151.71617 9 06-nov-94 03:36:56 06-nov-94 03:38:10 73.620 1.22700 10 06-nov-94 03:37:49 06-nov-94 03:38:10 20.910 .34850 [/B]