Oracle查詢誰把表鎖了

2021-09-30 07:55:09 字數 1833 閱讀 5989

--- 檢視鎖以system登陸

select lock_info.owner || '.' || lock_info.obj_name as obj_name, --物件名稱(已經被鎖住)  

lock_info.subobj_name as subobj_name, --子物件名稱(已經被鎖住)  

sess_info.machine as machine, --機器名稱

lock_info.session_id as session_id, --會話session_id  

sess_info.serial# as serial#, --會話serial#  

lock_info.ora_username as ora_username, --oracle系統使用者名稱

lock_info.os_username as os_username, --作業系統使用者名稱

lock_info.process as process, --程序編號

lock_info.obj_id as obj_id, --物件id  

lock_info.obj_type as obj_type, --物件型別

sess_info.logon_time as logon_time, --登入時間

sess_info.program as program, --程式名稱

sess_info.status as status, --會話狀態

sess_info.lockwait as lockwait, --等待鎖

sess_info.action as action, --動作

sess_info.client_info as client_info --客戶資訊

from (select obj.owner                as owner,

obj.object_name          as obj_name,

obj.subobject_name       as subobj_name,

obj.object_id            as obj_id,

obj.object_type          as obj_type,

lock_obj.session_id      as session_id,

lock_obj.oracle_username as ora_username,

lock_obj.os_user_name    as os_username,

lock_obj.process         as process

from (select *

from all_objects

where object_id in (select object_id from v$locked_object)) obj,

v$locked_object lock_obj

where obj.object_id = lock_obj.object_id) lock_info,

(select sid,

serial#,

lockwait,

status,

program,

action,

client_info,

logon_time,

machine

from v$session) sess_info

where lock_info.session_id = sess_info.sid;

解鎖:alter system kill session 'session_id,serial#';

如:alter system kill session '114,12928';

ORACLE鎖表查詢

select rule lpad decode l.xidusn 0,3,0 l.oracle username user name,o.owner,o.object name,o.object type,s.sid,s.serial from v locked object l,dba objec...

Oracle 鎖表 鎖表查詢 結束鎖表程序

1.oracle 鎖表 lock table 表名字in exclusive mode 所記錄 select from 表名字 for update 2.oracle 鎖表查詢 selectb.owner,b.object name,a.session id,a.locked mode from v...

Oracle鎖表及鎖表使用者查詢

可在pl sql中用如下sql語句來查詢當前資料庫中哪些表被鎖住了,並且是哪些使用者來鎖的這些表 select a.owner,object所屬使用者 a.object name,object名稱 表名 b.xidusn,b.xidslot,b.xidsqn,b.session id,鎖表使用者的s...