查询记录的锁定对象,select * from v$locked_object(身份必须是DBA权限),然后找到对应的sid和serial#杀掉了会话;
(2)找到锁定进程:
select p.spid, s.sid, s.serial# serial_num, s.username user_name, a.type object_type, s.osuser os_user_name, a.owner, a.object object_name,
decode(sign(48 - command), 1, to_char(command), 'Action Code #' ,to_char(command) ) action,
p.program oracle_process, s.terminal terminal, s.program program, s.status session_status
from v$session s, v$access a, v$process p
where s.paddr = p.addr and s.type = 'table' and a.sid = s.sid and a.object='test'
找到了这个表被哪个进程在用,也杀掉了。
(2)以DBA角色, 查看当前数据库里锁的情况可以用如下SQL语句:
select object_id,session_id,locked_mode from
v$locked_object;
select t2.username,t2.sid,t2.serial#,t2.logon_time
from v$locked_object t1,v$session t2
where t1.session_id=t2.sid order by t2.logon_time;
如果有长期出现的一列,可能是没有释放的锁。
我们可以用下面SQL语句杀掉长期没有释放非正常的锁:
alter system kill session 'sid,serial#';
---------------------
作者:wuqingyong
来源:CSDN
原文:https://blog.csdn.net/wuqingyong/article/details/1588287
版权声明:本文为博主原创文章,转载请附上博文链接!