–以下幾個為相關表
SELECT * FROM v$lock;
SELECT * FROM v$sqlarea;
SELECT * FROM v$session;
SELECT * FROM v$process ;
SELECT * FROM v$locked_object;
SELECT * FROM all_objects;
SELECT * FROM v$session_wait;
–檢視被鎖的表
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;
–檢視那個使用者那個程式照成死鎖
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;
–3.查出鎖定表的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;
這個語句將查詢到資料庫中所有的DML語句產生的鎖,還可以發現,
任何DML語句其實產生了兩個鎖,一個是表鎖,一個是行鎖。
–殺掉程式 sid,serial#
alter system kill session `210,11562`; 此處不能連線起來 要有空格,不然會報錯的例如(alter system kill session`210,11562`; )。
來自:https://www.cnblogs.com/XQiu/p/5212787.html