查看被锁的表和解锁

时间:2021-07-03 00:44:46

查看被锁的表

select b.owner,b.object_name,a.session_id,
a.locked_mode from v$locked_object a,dba_objects b where b.object_id = a.object_id;

查看xx用户xx进程的死锁

select b.username,b.sid,b.serial#,logon_time from v$locked_object a, v$session b where a.session_id = b.sid order by b.logon_time;

查看连接的进程

SELECT sid, serial#, username, osuser FROM v$session; 

查出锁定表的sid, serial#,os_user_name, machine_name, terminal,锁的type,mode

SELECT s.sid, s.serial#, s.username, s.schemaname, 
s.osuser, s.process, s.machine,
s.terminal, s.logon_time, l.type
FROM v$session s, v$lock l
WHERE s.sid = l.sid
AND s.username IS NOT NULL
ORDER BY sid;

–杀掉进程 sid,serial#

alter system kill session'210,11562';