-- 查詢出被鎖對象,并提供 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