dataiotech Labs
Scripts Library/oracle/#79
Script #79
oracle
Lockingread-onlyMin Version: 11g

Locked Objects and Lock Holders in Oracle

Shows which sessions hold locks on which objects. Gives object-level diagnosis for DDL and row lock issues.

#dba_waiters#enqueue#row-lock
oracle · sql
SELECT lo.session_id AS sid, s.serial#, s.username, s.status, s.machine,
       o.owner, o.object_name, o.object_type,
       DECODE(lo.locked_mode, 1,'NULL',2,'ROW SHARE',3,'ROW EXCL',4,'SHARE',5,'SHARE ROW EXCL',6,'EXCLUSIVE') AS lock_mode
FROM   v$locked_object lo
JOIN   dba_objects o ON o.object_id = lo.object_id
JOIN   v$session s   ON s.sid = lo.session_id
ORDER  BY o.owner, o.object_name;
Operational Notes & Remediation Guidance

Verify in a staging environment prior to running in production. This is a read-only diagnostic query; it does not acquire exclusive locks.

Production Safety & Execution Standards
  • This script is designed for read-only diagnostics; it does not alter schema or modify data directly.
  • Prior to executing on production systems under high load, verify the target database version (Min. Version: 11g).
  • Exercise caution with mutating actions (e.g., terminating sessions or dropping indexes) referenced in the notes section.

Engineering Triad: Related Runbooks & Incident Response

Which production incidents and emergency drills execute this script as a diagnosis step?

Runbook Library (63)
Related Alerts & Metrics
M43Oracle Blocked SessionsOracle