今天同事在操做Oracle數據庫表刪數據時忽然斷網,再次鏈接的時候刪數據就提示「record is locked by another user」,而後就百度找到了以下解決方案。數據庫
方案步驟:session
一、查鎖code
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;blog
二、解鎖(KILL)get
--alter system kill session 'sid,serial#';
alter system kill session '151,14678'; --151是sid,14678是serial#it
運行以上命令後,就能夠解決此問題。io
操做記錄:class
一、數據庫表被鎖;百度
二、查鎖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;
結果:
1 BCSA 64 40449 2016/10/9 15:38:05 2 BCSA 64 40449 2016/10/9 15:38:05 3 BCSA 64 40449 2016/10/9 15:38:05 4 BCSA 64 40449 2016/10/9 15:38:05
三、解鎖
alter system kill session '64,40449';