-- 查询出被锁对象,并提供 kill 脚本
SELECT S.SID, S.MACHINE, O.OBJECT_NAME, L.ORACLE_USERNAME, L.LOCKED_MODE, S.OSUSESR,
'ALTER SYSTEM KILL SESSION '''|| S.SID || ', '|| S.SERIAL#||''';' AS KILL_COMMAND
FROM V$LOCKED_OBJECT L, V$SESSION S, ALL_OBJECTS O
WHERE L.SESSION_ID=S.SID AND L.OBJECT_ID=O.OBJECT_ID