← Sessions & Locks
Oracle · Sessions & Locks

How to check active sessions in Oracle

List active Oracle user sessions with username, machine, program, and the SQL they are running.

Tested on11g12c18c19c21c23ai26ai

List active user sessions right now — who they are, where they connect from, and what SQL they run. Excludes Oracle background processes.

SELECT s.sid, s.serial#, s.username, s.status, s.machine, s.program,
       s.module, s.osuser, s.last_call_et,
       q.sql_id, SUBSTR(q.sql_text, 1, 80) AS sql_text
FROM   v$session s
LEFT JOIN v$sql q
       ON q.sql_id       = s.sql_id
      AND q.child_number = s.sql_child_number
WHERE  s.type   = 'USER'
AND    s.status = 'ACTIVE'
ORDER BY s.last_call_et DESC;
sessionsv$sessionactive