oracle檢視被鎖的表和解鎖

2021-09-28 17:43:29 字數 1221 閱讀 8598

oracle檢視被鎖的表和解鎖

--以下幾個為相關表

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

notnull

order

by sid;

這個語句將查詢到資料庫中所有的dml語句產生的鎖,還可以發現,

任何dml語句其實產生了兩個鎖,乙個是表鎖,乙個是行鎖。

--殺掉程序 sid,serial#

alter system kill session'210,11562'

;

oracle檢視被鎖的表和解鎖

檢視鎖表程序sql語句1 select sess.sid,sess.serial lo.oracle username,lo.os user name,ao.object name,lo.locked mode from v locked object lo,dba objects ao,v ses...

oracle檢視被鎖的表和解鎖

以下幾個為相關表 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 sele...

oracle檢視被鎖的表和解鎖

以下幾個為相關表 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 sele...