oracle 锁 (查询/解锁语句)

来源:互联网 发布:计算机编程是干什么的 编辑:程序博客网 时间:2024/04/30 01:22
 --oracle 锁 (查询/解锁语句)


-- 查看哪个表被锁
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
--查看是哪个session引起的
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  *  from table where id=16701 for update 锁住一张表


--通过以下语句可查询出被锁住的对象
SELECT OBJECT_ID,
       SESSION_ID,
       SERIAL#,
       ORACLE_USERNAME,
       OS_USER_NAME,
       S.PROCESS
  FROM V$LOCKED_OBJECT A, V$SESSION S
 WHERE A.SESSION_ID = S.SID


 
--通过下列语句进行解锁
 alter system kill session 'sid,serial#';
原创粉丝点击