SQL for getting active user sessions:
select /*+RULE */ SID,SPID,ses.SERIAL#,ses.USERNAME,ses.module,SQL_TEXT,pro.TERMINAL
from v$sqlarea sql, v$session ses,v$process pro
where HASH_VALUE=SQL_HASH_VALUE
and status = 'ACTIVE'
and ses.username is not null
and ses.PADDR = pro.ADDR
order by sql_text;
SQL to get blocking sessions and SQL's:
select /*+RULE */s.username username , s.sid,s.serial#, p.spid,o.OBJECT_NAME objectname,s.process,substr(s.module,1,20) module,
to_char(sysdate - s.last_call_et/60/60/24,'DD-MON-YYYY HH24:MI') last_call,
substr(w.event,1,24) event,
decode(block ,0,'NO','YES') BLOCKER,
decode(request,0,'NO','YES') WAITER
from v$lock l, v$session s, v$process p, v$session_wait w,v$locked_object lb, dba_objects o where (l.request > 0 or l.block > 0 ) and s.sid=l.sid and p.addr=s.paddr and s.last_call_et > 600 and w.sid=s.sid and s.sid = lb.SESSION_ID and lb.OBJECT_ID = o.OBJECT_ID order by last_call_et desc;
To find out the invalid objects :
select object_name,object_type from dba_objects where username='schema_name' and status ='INVALID';
To find out the locked objects:
select a.OBJECT_NAME,b.SESSION_ID,b.ORACLE_USERNAME,b.OS_USER_NAME,b.PROCESS,b.LOCKED_MODE
from dba_objects a, v$locked_object b where b.OBJECT_ID=a.OBJECT_ID;
No comments:
Post a Comment