Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 3

column minutes format 99999;

column lock_type format a12;


column lock_held format a10;
column lock_request format a10;
column sid format 999999;
column module format a40;
column action format a10;
column object_name format a30;
column seqnum format 99999999;
column ctime format 999999;
column serial# format 99999;
set linesize 300
set pagesize 5000
spool glocks.txt
Prompt
Prompt Waiting for locks...
Prompt
select distinct
vl.ctime/100 minutes,
-- vl.kaddr lockaddr,
decode(vl.type,'MR','Media Recovery','RT','Redo Thread',
'UN','User Name','TX','Transaction','TM','DML',
'UL','PL/SQL User Lock','DX','Distributed Xaction',
'CF','Control File','IS','Instance State','FS','File Set',
'IR','Instance Recovery','ST','Disk Space Transaction',
'TS','Temp Segment','IV','Library Cache Invalida-tion',
'LS','Log Start or Switch','RW','Row Wait','SQ','Sequence Numb
er',
'TE','Extend Table','TT','Temp Table','Unknown'||' '||vl.type)
Lock_Type,
decode (vl.lmode,0,'None',1,'Null',2,'RowShare',3,'RowExcl',4,'Share',5,'ShRo
wEx',6,'Exclusive','Unknown'||'-'||vl.lmode) Lock_Held,
decode (vl.request,0,'None',1,'Null',2,'RowShare',3,'RowExcl',4,'Share',5,'Sh
RowEx',6,'Exclusive','Unknown'||' - '||vl.request) Lock_Request,
-- vs.lockwait,
ao.object_name,
-- vlo.xidsqn seqnum,
vs.sid,
vs.serial#,
vs.action,
decode(instr(vs.module,'01@'),0,vs.module,substr(vs.module,instr(vs.module,'s
ql/Z')+4)) module
from
all_objects ao,
gv$locked_object vlo,
gv$session vs,
gv$lock vl,
gv$session vsw
where
vsw.lockwait is not null and
vl.kaddr = vsw.lockwait and
vs.sid = vl.sid and
vlo.session_id = vs.sid and
ao.object_id = vlo.object_id
order by
minutes,
ao.object_name
;
--Prompt
--Prompt Who has the objects locked....
--Prompt
--select distinct
-- vl.ctime,
---- vl.kaddr lockaddr,
-- decode(vl.type,'MR','Media Recovery','RT','Redo Thread',
-- 'UN','User Name','TX','Transaction','TM','DML',
-- 'UL','PL/SQL User Lock','DX','Distributed Xaction',
-- 'CF','Control File','IS','Instance State','FS','File Set',
-- 'IR','Instance Recovery','ST','Disk Space Transaction',
-- 'TS','Temp Segment','IV','Library Cache Invalida-tion',
-- 'LS','Log Start or Switch','RW','Row Wait','SQ','Sequence Nu
mber',
-- 'TE','Extend Table','TT','Temp Table','Unknown') Lock_Type,
-- decode (vl.lmode,0,'None',1,'Null',2,'RowShare',3,'RowExcl',4,'Share',5,'Sh
RowEx',6,'Exclusive','Unknown') Lock_Held,
-- decode (vl.request,0,'None',1,'Null',2,'RowShare',3,'RowExcl',4,'Share',5,'
ShRowEx',6,'Exclusive','Unknown') Lock_Request,
---- vs.lockwait,
-- ao.object_name,
-- vlo.xidsqn seqnum,
-- vs.sid,
-- decode(instr(vs.module,'01@'),0,vs.module,substr(vs.module,instr(vs.module,
'sql/Z')+4)) module,
-- vs.action
--from
-- all_objects ao,
-- v$lock vl,
-- v$session vs,
-- v$locked_object vlo,
-- v$locked_object vlow,
-- v$lock vlw,
-- v$session vsw
--where
-- vsw.lockwait is not null and
-- vlw.kaddr = vsw.lockwait and
-- vlow.session_id = vsw.sid and
-- vlo.object_id = vlow.object_id and
-- vs.sid = vlo.session_id and
-- vl.sid = vs.sid and
-- ao.object_id = vlo.object_id
--order by
-- vl.ctime,
-- ao.object_name,
-- vlo.xidsqn
--;
Prompt
Prompt Who is holding locks...
Prompt
select distinct
vl.ctime/100 minutes,
-- vl.kaddr lockaddr,
decode(vl.type,'MR','Media Recovery','RT','Redo Thread',
'UN','User Name','TX','Transaction','TM','DML',
'UL','PL/SQL User Lock','DX','Distributed Xaction',
'CF','Control File','IS','Instance State','FS','File Set',
'IR','Instance Recovery','ST','Disk Space Transaction',
'TS','Temp Segment','IV','Library Cache Invalida-tion',
'LS','Log Start or Switch','RW','Row Wait','SQ','Sequence Numb
er',
'TE','Extend Table','TT','Temp Table','Unknown'||' - '||vl.typ
e) Lock_Type,
decode (vl.lmode,0,'None',1,'Null',2,'RowShare',3,'RowExcl',4,'Share',5,'ShRo
wEx',6,'Exclusive','Unknown'||' - '||vl.lmode) Lock_Held,
decode (vl.request,0,'None',1,'Null',2,'RowShare',3,'RowExcl',4,'Share',5,'Sh
RowEx',6,'Exclusive','Unknown'||' - '||vl.request) Lock_Request,
-- vs.lockwait,
ao.object_name,
-- vlo.xidsqn seqnum,
vs.sid,
vs.serial#,
vs.status,
vs.osuser,
decode(vs.action,null,vlo.oracle_username,vs.action) users,
decode(instr(vs.module,'01@'),0,vs.module,substr(vs.module,instr(vs.module,'s
ql/Z')+4)) module
from
all_objects ao,
gv$locked_object vlo,
gv$lock vl,
gv$session vs
where
vs.module is not null and
vl.sid = vs.sid and
vlo.session_id = vs.sid and
ao.object_id = vlo.object_id
order by
minutes desc,
ao.object_name
;
spool off;
--host "start notepad.exe locks.txt"

You might also like