大家好,欢迎来到IT知识分享网。
1. 首先查看数据库中哪些表被锁了,找到session ID:
使用sql:
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;
OWNER :数据表的所有者用户
OBJECT_NAME: 被锁住的表名
SESSION_ID: 会话ID
LOCKED_MODE: 锁级别
锁级别分为6级:
1级锁有:Select
2级锁有:Select for update,Lock For Update,Lock Row Share
3级锁有:Insert, Update, Delete, Lock Row Exclusive
4级锁有:Create Index, Lock Share
5级锁有:Lock Share Row Exclusive
6级锁有:Alter table, Drop table, Drop Index, Truncate table, Lock Exclusive
2.再执行该语句,查看会话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;
3.杀会话
alter system kill session ‘sid,serial#’;
例子:
alter system kill session ‘20,30153’; —–这个是我刚才杀死会话前的执行语句
如果有ora-00031错误,则在后面加immediate;
alter system kill session ‘20,30153’ immediate;
————————————————
还有一种简便快捷办法
select ‘alter system kill session ”’||sess.sid||’,’||sess.serial#||”’;’
from v$locked_object lo,
dba_objects ao,
v$session sess
where ao.object_id = lo.object_id and lo.session_id = sess.sid
————————————————
版权声明:本文为CSDN博主「lichongxyz」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/lichongxyz/article/details/126851107
免责声明:本站所有文章内容,图片,视频等均是来源于用户投稿和互联网及文摘转载整编而成,不代表本站观点,不承担相关法律责任。其著作权各归其原作者或其出版社所有。如发现本站有涉嫌抄袭侵权/违法违规的内容,侵犯到您的权益,请在线联系站长,一经查实,本站将立刻删除。 本文来自网络,若有侵权,请联系删除,如若转载,请注明出处:https://yundeesoft.com/32090.html