问题描述: 数据表不能修改或删除数据,如果操作则会卡住,这可能是锁表了。
解决步骤:
(1)查看哪个表被锁
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;
(2)查看导致锁表的session(多次查询sql,如果该session一直存在,则是导致锁表的session)
select a.os_user_name, c.owner, c.object_name, b.sid, b.serial#, logon_time
from v$locked_object a,v$session b, dba_objects c
where a.session_id = b.sid
and a.object_id = c.object_id
order by b.logon_time;
导致锁表的某条session记录的【sid】和【serial#】这两个字段,用于第三步骤杀掉对应进程。
(3)杀掉对应进程
alter system kill session '1058,32';
备注:上面sql中1058是sid,32是serial#。