SELECT dob.object_name table_name,
lo.locked_mode,
lo.session_id,
vss.serial#,
vss.status,
vps.spid,
vss.action action,
vss.osuser osuser,
vss.machine, --机器名
vss.terminal, --终端
vss.client_identifier, --客户端标识符
vss.process ap_pid,
vps.spid db_pid,
'alter system kill session '
|| ''''
|| lo.session_id
|| ','
|| vss.serial#
|| ''';'
kill_command
FROM v$locked_object lo,
dba_objects dob,
v$session vss,
v$process vps
WHERE lo.object_id = dob.object_id
AND lo.session_id = vss.sid
AND vss.paddr = vps.addr
ORDER BY 2, 3, dob.object_name;