oracle表解锁

#####数据库用户被锁,解锁步骤####
1.以sys/oracle登录数据库,执行以下命令,查出具体是哪个用户被锁了
Select t.username From Dba_Users t Where t.account_status='LOCKED(TIMED)';

2.执行解锁命令
Alter User 用户名 Account Unlock;


####数据表被锁####
1.以sys/oracle登录数据库,执行以下命令,查出是哪个表被锁了
select nvl(S.USERNAME,'Internal') username, 
 nvl(S.TERMINAL,'None') terminal, 
 L.SID||','||S.SERIAL# KILL_ID, 
 U1.NAME||'.'||substr(T1.NAME,1,20) tab, 
 decode(L.LMODE,1,'No Lock', 
  2,'Row Share', 
  3,'Row Exclusive', 
  4,'Share', 
  5,'Share Row Exclusive', 
  6,'Exclusive',null) lmode, 
 decode(L.REQUEST,1,'No Lock', 
  2,'Row Share', 
  3,'Row Exclusive', 
  4,'Share', 
  5,'Share Row Exclusive', 
  6,'Exclusive',null) request 
from V$LOCK L,  
 V$SESSION S, 
 SYS.USER$ U1, 
 SYS.OBJ$ T1 
where L.SID = S.SID  
and T1.OBJ# = decode(L.ID2,0,L.ID1,L.ID2)  
and U1.USER# = T1.OWNER# 
And decode(L.LMODE,1,'No Lock', 
  2,'Row Share', 
  3,'Row Exclusive', 
  4,'Share', 
  5,'Share Row Exclusive', 
  6,'Exclusive',null) ='Row Exclusive'
and S.TYPE != 'BACKGROUND' 
order by 1,2,5 

上面这个sql运行后的第3列是个id,比如‘17,9011’

2.kill掉查出来的那个id
alter system kill session '17,9011'
注意这个id是一起的,并不是一个17,一个9011,所以不能分开kill,要在一个语句中kill
---------------------
作者:liangyf33
来源:CSDN
原文:https://blog.csdn.net/liangyf33/article/details/84565250
版权声明:本文为博主原创文章,转载请附上博文链接!

posted on 2019-07-24 17:12  别动我的锅  阅读(141)  评论(0)    收藏  举报

导航

levels of contents