/*
*locked
*query locked object and analyse reason,kill it
* */
select 'alter system kill session ''' || sid || ',' || serial# || ''';'
from (select distinct a.sid,
a.serial#,
status,
machine,
lockwait,
logon_time
from v$session a, v$locked_object b
where (a.status = 'active' or a.status = 'inactive')
and a.sid = b.session_id
and b.oracle_username = 'xyhistest' --加上使用者名稱可過濾使用者資源
) /*2、批量執行第一步生成的語句
alter system kill session 'sid,serial#';
alter system kill session '6976,33967';*/
/*3、查詢oracle使用者名稱,機器名,鎖表物件*/
select l.session_id sid,
s.serial#,
l.locked_mode,
l.oracle_username,
l.os_user_name,
s.machine,
s.terminal,
o.object_name,
s.logon_time
from v$locked_object l, all_objects o, v$session s
where l.object_id = o.object_id
and l.session_id = s.sid
order by sid, s.serial#;
/*3.或者*/
select s.sid, s.osuser, p.spid as ospid, s.machine, s.terminal, s.program
from v$session s, v$process p
where s.sid = 6 --session_id
and s.paddr = p.addr;
/*4、查詢是執行何sql語句導致鎖表的*/
select b.sql_text
from v$session a, v$sql b
where a.sid = 6 --session_id
and a.sql_address = b.address(+);
/*5、查詢是執行何sql語句導致鎖表的*/
select l.session_id sid,
s.serial#,
l.locked_mode,
l.oracle_username,
s.user#,
l.os_user_name,
s.machine,
s.terminal,
a.sql_text,
a.action
from v$sqlarea a, v$session s, v$locked_object l
where l.session_id = s.sid
and s.prev_sql_addr = a.address
order by sid, s.serial#;
oracle 檢視鎖表情況並處理鎖表
locked query locked object and analyse reason,kill it select alter system kill session sid serial from select distinct a.sid,a.serial status,machine,l...
mysql檢視鎖表情況
mysql show status like table variable name value table locks immediate 105 table locks waited 3 table locks immediate 指的是能夠立即獲得表級鎖的次數 table locks wait...
Oracle 檢視 物件 持有鎖的情況
同事在測試庫上對乙個表加字段,提示 ora 00054,資源忙。應該是表物件的鎖沒有釋放。用如下sql 檢視一下系統中相關物件上鎖的情況 view plain select s.sidsession id,s.username,decode lmode,0,none 1,null 2,row s s...