Session info with pid, sql_id and sql_text



select ses.sid, 
ses.serial#, 
ses.username, 
ses.terminal, 
sq.sql_id, 
sq.sql_text, 
p.pid, 
p.spid
from v$session ses 
join v$sql sq
on ses.sql_id = sq.sql_id
join v$process p
on ses.paddr=p.addr;


SELECT s.inst_id,
       s.sid,
       s.serial#,
       p.spid,
       s.username,
       s.program
FROM   gv$session s
       JOIN gv$process p ON p.addr = s.paddr AND p.inst_id = s.inst_id
WHERE  s.type != 'BACKGROUND';

-- Get sql text for a certain PID

select
s.username su,
substr(sa.sql_text,1,540) txt
from v$process p,
v$session s,
v$sqlarea sa
where p.addr=s.paddr
and s.username is not null
and s.sql_address=sa.address(+)
and s.sql_hash_value=sa.hash_value(+);
and spid=&SPID;

Comments: Leave Comment

* The email will not be published on the website.