【数据库】死锁排查方式
定位
查是否锁表
select username,lockwait,status,machine,program from v$session where sid in
(select session_id from v$locked_object);
查锁表sql
select sql_text from v$sql where hash_value in
(select sql_hash_value from v$session where sid in
(select session_id from v$locked_object));
到这里就可以根据sql进行分析
临时处理方式
查sid
SELECT s.sid||','|| s.serial#, s.sid, s.serial#, l.type, o.object_name
FROM v$lock l
JOIN dba_objects o ON l.id1 = o.object_id
JOIN v$session s ON l.sid = s.sid
WHERE o.object_type = 'TABLE'
AND l.type IN ('TM', 'TX')
order by sid;
根据sid进行kill
ALTER SYSTEM KILL SESSION '862,9556';