Oreacle
查看锁表
SELECT
sess.sid,
sess.serial#,
lo.oracle_username, -- 登陆账号名称
lo.os_user_name, -- 登录电脑名称
ao.object_name, -- 被锁表名
lo.locked_mode -- 死锁级别
FROM
v$locked_object lo,
dba_objects ao,
v$session sess
WHERE
ao.object_id = lo.object_id
AND lo.session_id = sess.sid;
死锁级别:
0:none
1:null 空
2:Row-S 行共享(RS):共享表锁
3:Row-X 行专用(RX):用于行的修改
4:Share 共享锁(S):阻止其他DML操作
5:S/Row-X 共享行专用(SRX):阻止其他事务操作
6:exclusive 专用(X):独立访问使用
解锁方法
alter system kill session '68,51'; -- 分别为SID和SERIAL#号
查看引起锁表的sql语句
SELECT
A.USERNAME,
A.MACHINE,
A.PROGRAM,
A.SID,
A.SERIAL#,
A.STATUS,
C.PIECE,
C.SQL_TEXT
FROM
V$SESSION A,
V$SQLTEXT C
WHERE
A.SID IN ( SELECT DISTINCT T2.SID FROM V$LOCKED_OBJECT T1, V$SESSION T2 WHERE T1.SESSION_ID = T2.SID )
AND A.SQL_ADDRESS = C.ADDRESS ( + )
ORDER BY
C.PIECE;