← Sessions & Locks
Oracle · Sessions & Locks
How to check idle sessions over a threshold in Oracle
List Oracle sessions idle for more than N seconds so you can decide whether to disconnect them.
Tested on11g12c18c19c21c23ai26ai
LAST_CALL_ET is the number of seconds since the session last called into the server. Filtering INACTIVE user sessions above a threshold surfaces dead connections that are still holding a slot.
ACCEPT p_min_idle_sec NUMBER PROMPT 'Idle threshold in seconds (e.g. 3600): '
SELECT sid, serial#, username, machine, program, osuser,
status, last_call_et AS idle_sec,
ROUND(last_call_et / 60, 1) AS idle_min,
logon_time
FROM v$session
WHERE type = 'USER'
AND status = 'INACTIVE'
AND last_call_et > &&p_min_idle_sec
ORDER BY last_call_et DESC;sessionsidlelast_call_et