当多个会话想同时访问一行数据,就有可能发生锁的争用。
查询会话锁定状态:
USERNAME SID RBS SLOT SEQ LMODE REQUEST
---------- ---------- ---------- ---------- ---------- ---------- ----------
SCOTT 146 4 47 21557 0 6
SCOTT 150 4 47 21557 6 0
SCOTT 161 4 47 21557 0 6
LMODE表示当前获得的锁,REQUEST表示想要获得的锁。
SID BLOCKING_SESSION USERNAME BLOCKING_SESSION_STATUS
---------- ---------------- ---------- -----------------------
146 150 SCOTT VALID
161 150 SCOTT VALID
150 SCOTT NO HOLDER
VALID 被BLOCK
NO HOLDER 没有被BLOCK
如果要关闭会话:
单引号中分别是,'SID, SERIAL#',这两个都是V$SESSION中的列。
查询会话锁定状态:
点击(此处)折叠或打开
- select /*+ ordered */ username, v$lock.sid, trunc(id1/power(2,16)) rbs,
- bitand(id1,to_number('ffff','xxxx'))+0 slot,
- id2 seq, lmode, request
- from v$lock, v$session
- where v$lock.type = 'TX'
- and v$lock.sid = v$session.sid;
USERNAME SID RBS SLOT SEQ LMODE REQUEST
---------- ---------- ---------- ---------- ---------- ---------- ----------
SCOTT 146 4 47 21557 0 6
SCOTT 150 4 47 21557 6 0
SCOTT 161 4 47 21557 0 6
-
0 - none
-
1 - null (NULL)
-
2 - row-S (SS)
-
3 - row-X (SX)
-
4 - share (S)
-
5 - S/Row-X (SSX)
-
6 - exclusive (X)
点击(此处)折叠或打开
- SELECT sid, blocking_session, username, blocking_session_status
- FROM v$session
- WHERE username='SCOTT'
- ORDER BY blocking_session;
SID BLOCKING_SESSION USERNAME BLOCKING_SESSION_STATUS
---------- ---------------- ---------- -----------------------
146 150 SCOTT VALID
161 150 SCOTT VALID
150 SCOTT NO HOLDER
NO HOLDER 没有被BLOCK
如果要关闭会话:
点击(此处)折叠或打开
- alter system kill session '11,18';
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/22621861/viewspace-1284497/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/22621861/viewspace-1284497/