一、查看锁表语句
SELECTsess.sid,sess.serial#,lo.oracle_username, -- 登陆账号名称lo.os_user_name,-- 登录电脑名称ao.object_name, -- 被锁表名lo.locked_mode-- 死锁级别FROMv$locked_object lo,dba_objects ao,v$session sess WHEREao.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语句
SELECTA.USERNAME,A.MACHINE,A.PROGRAM,A.SID,A.SERIAL#,A.STATUS,C.PIECE,C.SQL_TEXT FROMV$SESSION A,V$SQLTEXT C WHEREA.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 BYC.PIECE;