Sunday, September 20, 2009

Check Session Details in Oracle

set pages 49999
set lines 300
col PID for a7
col SID for 9999999999
col ser# for a7
col box for a29
col status for a9
col username for a20
col os_user for a12
col program for a25
col LOGON_TIME for a14
col module for a14
col machine for a10
select b.status as status,sql_hash_value,prev_hash_value,module,machine,
to_char(a.spid) as pid, to_char(b.sid) as sid, to_char(b.serial#) as "ser#", substr(b.machine,1,25) as box, b.username as username,
b.osuser as os_user, b.program program, to_char(b.LOGON_TIME,'dd-mon hh24:mi') LOGON_TIME from v$session b, v$process a where
b.paddr = a.addr
and type='USER'
and b.sid in (&session_id)
order by 3;

SET LINESIZE 500
SET PAGESIZE 1000
SET VERIFY OFF
col SQL_TEXT for a100

SELECT b.sid,a.sql_text
FROM v$sqltext_with_newlines a,
v$session b
WHERE a.address = b.sql_address
AND a.hash_value = b.sql_hash_value
AND b.sid in (&session_id)
ORDER BY b.sid,a.piece;

PROMPT
SET PAGESIZE 14

No comments: