- 0
- 0
- 约11.04万字
- 约 25页
- 2016-11-27 发布于河南
- 举报
Oracle 锁
Oracle 锁
--产生在数据库中持有的锁的报表
--查看某个数据库对象是否被锁
--查询数据库阻塞其他会话的锁所持有的对象
--查看谁阻塞了谁
--所有TM阻塞情况
--oracle TX锁的等待序列
--用户锁等待阻塞信息报告
--持有锁的会话
--latch阻塞的检索
--用于鉴别系统中闩性能的脚本
--列举用于闩竞争的信息
--检索闩睡眠率
--使用v$session wait视图来鉴别闩竞争
脚本
select s.username, s.sid, l.type, l.id1, l.id2, l.lmode, l.request, p.spid PID
from v$lock l, v$session s, v$process p
where s.sid = l.sid
and p.addr = s.paddr
and s.username is not null
order by id1, s.sid, request;
--产生在数据库中持有的锁的报表
select b.sid, c.username, c.osuser, c.terminal,
decode(b.id2, 0, a.object_name, Trans- || to_char(b.id1)) object_name,
b.type,
decode(b.lmode, 0, -Waiting-,
1, Null,
2, Row Share,
3, Row Excl,
4, Share,
5, Sha Row Exc,
6, Exclusive, Other) Lock Mode,
decode(b.request, 0, ,
1, Null,
2, Row Share,
3, Row Excl,
4, Share,
5, Sha Row Exc,
6, Exclusive, Other) Req Mode
from dba_objects a, v$lock b, v$session c
where a.object_id(+) = b.id1
and b.sid = c.sid
and c.username is not null
order by b.sid, b.id2;
--After Run
SID USERNAME OSUSER TERMINAL OBJECT_NAME TYPE Lock Mode Req Mode
2611 AICHNL weblogic TransTX Exclusive
2613 AICHNL weblogic TransTX Exclusive
--查看某个数据库对象是否被锁
alter session set nls_date_format=yyyy-mm-dd hh24:mi:ss;
set wrap off
set linesize 200
col username for a10
col logon_time for a20
col lock_level for a10
col owner for a10
col object_name for a30
col object_type for a15
col status for a10
col program for a30
col osuser for a10
SELECT /*+ rule */ s.username,s.logon_time,
decode(l.type,TM,TABLE LOCK,TX,ROW LOCK,NULL) LOCK_LEVEL,
o.owner,o.object_name,o.object_type,
s.sid,s.serial#,p.spid,s.status,s.program,s.osuser
FROM v$session s,v$lock l,dba_objects o,v$pro
原创力文档

文档评论(0)