如何将数据库中被锁表解锁
SELECT sn.username, m.SID,sn.SERIAL#, m.TYPE,
DECODE (m.lmode,
0, \'None\',
1, \'Null\',
2, \'Row Share\',
3, \'Row Excl.\',
4, \'Share\',
5, \'S/Row Excl.\',
6, \'Exclusive\',
lmode, LTRIM (TO_CHAR (lmode, \'990\'))
) lmode,
DECODE (m.request,
0, \'None\',
1, \'Null\',
2, \'Row Share\',
3, \'Row Excl.\',
4, \'Share\',
5, \'S/Row Excl.\',
6, \'Exclusive\',
request, LTRIM (TO_CHAR (m.request, \'990\'))
) request,
m.id1, m.id2
FROM v$session sn, v$lock m
WHERE (sn.SID = m.SID AND m.request != 0) --存在锁请求,即被阻塞
OR ( sn.SID = m.SID --不存在锁请求,但是锁定的对象被其他会话请求锁定
AND m.request = 0
AND lmode != 4
AND (id1, id2) IN (
SELECT s.id1, s.id2
FROM v$lock s
WHERE request != 0 AND s.id1 = m.id1
AND s.id2 = m.id2)
)
ORDER BY id1, id2, m.request;
通过以上查询知道了sid和 SERIAL#就可以开杀了
alter system kill session \'sid,SERIAL#\';
- 上一篇: 利用数据库复制技术 实现数据同步更新
- 下一篇: SQL Server日期计算