找出占用资源的会话,并删除
1:找出所有被锁的对象,定位出哪个回话占用
select l.session_id,o.owner,o.object_name
from v$locked_object l,dba_objects o
where l.object_id=o.object_id
结果:
session_id owner object_name
158 SA TEST_1
146 SA TEST_1
131 SA TEST_3
136 SA TEST_2
对比想要创建的索引,定位哪些会话需要被删除
2:找出所有照成锁的会话
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;
结果:
username sid serial# logon_time
SA 158 15184 2014/12/4 14:55:59
SA 146 8229 2014/12/4 15:23:22
SA 136 14314 2014/12/4 16:09:59
SA 131 54 2014/12/4 16:10:06
3:kill 所有占用资源的会话
命令形式:alter system kill session 'sid,serial#';
占用test_1的资源的会话:
alter system kill session '158,15184';
alter system kill session '146 ,8229';