, . SQL * Plus script , . Oracle Enterprise Manager (- Oracle) " ".
, - - , , ...
REM Purpose
REM
REM Display locks currently held and requested. Displays which session a
REM blocked lock is waiting for.
REM
REM Ver Who When What
REM
REM 1.0 DrB 12-Dec-97 Initial version
col uname head "Username" form a12
col sid head "SID" form 999
col ltype head "Type" form a4
col lmode head "Mode" form a10
col blocked head "Wait" form a4
col details head "Details" form a40
set verify off
set pause on
accept user prompt "Username [%]: "
select SubStr('alter system kill session ''' || s.sid || ',' || s.serial
decode (l.lmode,1,'Null',
2,'Row-S',
3,'Row-X',
4,'Share',
5,'S/Row-X',
6,'Exclusive') lmode,
decode (l.request,0,'No','Yes') blocked,
u.username||'.'||o.name details,
Nvl(s.Program, s.Module) What
from v$session s, v$lock l, sys.obj$ o, all_users u
where s.username like nvl(upper('&user'||'%'),'%')
and s.sid = l.sid
and l.id1 = o.obj
and o.owner
union all
select SubStr('alter system kill session ''' || s.sid || ',' || s.serial
decode (l.type,'TX','TX',
'UL','USR',
'SYS') ltype,
decode (l.lmode,1,'Null',
2,'Row-S',
3,'Row-X',
4,'Share',
5,'S/Row-X',
6,'Exclusive') lmode,
decode (l.request,0,'No','Yes') blocked,
decode (l.request,0,null,'Waiting on session '||to_char(b.sid)) details,
Nvl(s.Program, s.Module) What
from v$session s, v$lock l, v$lock b
where s.username like nvl(upper('&user'||'%'),'%')
and s.sid = l.sid
and l.type != 'TM'
and l.id1 = b.id1(+)
and b.request(+) = 0
order by 5 desc,3 desc,2,1;
set verify on
REM End of file