查询被锁表
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;
拼接去锁sql
select 'alter system kill session ''' ||s.sid||','||s.serial#||'''; ' from v$locked_object l,dba_objects o ,v$session s where l.object_id = o.object_id and l.session_id=s.sid;
总结
使用以上sql语句,可以解决死锁问题。拼接去锁sql,只是显示出要执行的语句,还要把结果单独执行。