查詢資料庫中鎖的持有者和被阻塞者的sql
朋友介紹的**,感覺不錯,與大家分享
select
s1.username "waiting user"
, s1.osuser "os user"
, w.session_id "sid"
, p1.spid "pid"
, s2.username "holding user"
, s2.osuser "os user"
, h.session_id "sid"
, p2.spid "pid"
from
sys.v_$process p1
, sys.v_$process p2
, sys.v_$session s1
, sys.v_$session s2
, dba_locks w
, dba_locks h
where
h.mode_held != 'none'
and h.mode_held != 'null'
and w.mode_requested != 'none'
and w.lock_type (+) = h.lock_type
and w.lock_id1 (+) = h.lock_id1
and w.lock_id2 (+) = h.lock_id2
and w.session_id = s1.sid (+)
and h.session_id = s2.sid (+)
and s1.paddr = p1.addr (+)
and s2.paddr = p2.addr (+)
/
mysql資料庫中查詢表是否被鎖
檢視表是否被鎖 直接在mysql命令列執行 show engine innodb status g。檢視造成死鎖的sql語句,分析索引情況,然後優化sql.然後show processlist,檢視造成死鎖占用時間長的sql語句。show status like lock 檢視表被鎖狀態和結束死鎖步...
MySQL 資料庫中查詢是否被鎖表
直接在mysql命令列執行 show engine innodb status g。檢視造成死鎖的sql語句,分析索引情況,然後優化sql.然後show processlist,檢視造成死鎖占用時間長的sql語句。show status like lock 1.檢視表被鎖狀態show open ta...
資料庫中的表被鎖了
1.下面的語句用來查詢哪些物件被鎖 select object name,machine,s.sid,s.serial from v locked object l,dba objects o v session s where l.object id o.object id and l.sessi...