Oracle 10g: Find Sessions

How to retrieve session information:

select S.LOGON_TIME ,sid, serial#, username, command, lockwait, status, osuser, sql_text, machine
from v$session s, v$sqlarea q
where s.sql_hash_value = q.hash_value
and s.sql_address = q.address
and osuser = 'zzz'
and s.username = 'xxx'
order by sql_text;
--for big queries:
--==========
select sid, serial#, username, command, lockwait, status, osuser, machine, n.sql_text, piece
from v$session s, v$sqlarea q, v$sqltext_with_newlines n
where s.sql_hash_value = q.hash_value and s.sql_hash_value = n.hash_value
and s.sql_address = q.address
and s.username = 'xxx'
and osuser = 'zzz'
ORDER BY piece;

Leave a Reply