select o.owner,o.object_name,s.sid,s.serial#,s.USERNAME,s.STATUS,s.machine,s.PROGRAM,'alter system kill session ' || chr(39) || to_char(s.SID) || ',' || to_char( s.SERIAL# ) || chr(39) || ';' as cmd
from v$locked_object l,dba_objects o ,v$session s
where l.object_id = o.object_id
and l.session_id=s.sid --and s.STATUS = 'ACTIVE'
union
SELECT DISTINCT "SYS"."DBA_DDL_LOCKS"."OWNER",
"SYS"."DBA_DDL_LOCKS"."NAME",
"SYS"."V_$SESSION"."SID",
"SYS"."V_$SESSION"."SERIAL#",
"SYS"."V_$SESSION"."USERNAME",
"SYS"."V_$SESSION"."STATUS",
"SYS"."V_$SESSION"."MACHINE",
"SYS"."V_$SESSION"."PROGRAM",'alter system kill session '|| chr(39) || to_char("SYS"."V_$SESSION"."SID") || ',' || to_char( "SYS"."V_$SESSION"."SERIAL#" ) || chr(39) || ';' as cmd
FROM "SYS"."DBA_DDL_LOCKS","SYS"."V_$SESSION"
WHERE ( "SYS"."DBA_DDL_LOCKS"."SESSION_ID" = "SYS"."V_$SESSION"."SID" )
AND ( SYS."V_$SESSION"."STATUS" = 'ACTIVE' )
所有锁住的表查询出来之后,找到对应的表后的alter 语句,执行了就杀了该表的死锁进程;
该问题的原因:可能存在两个语句同时对该表做更新或删除操作;导致死锁;