Skip to content

Instantly share code, notes, and snippets.

@mehdip2007
Created April 5, 2020 10:22
Show Gist options
  • Save mehdip2007/fa523233ef6bf66d6a6069c758fe147b to your computer and use it in GitHub Desktop.
Save mehdip2007/fa523233ef6bf66d6a6069c758fe147b to your computer and use it in GitHub Desktop.
find tables which locked generally or specific table
SELECT oracle_username || ' (' || s.osuser || ')' username
, s.sid || ',' || s.serial# sess_id
, owner || '.' || object_name object
, object_type
, CURSOR((SELECT DECODE (l.block, 0, 'Not Blocking', 1, 'Blocking', 2, 'Global') FROM v$lock l WHERE l.id1 = v.object_id)) status
, DECODE (v.locked_mode, 0, 'None',
1, 'Null',
2, 'Row-S (SS)',
3, 'Row-X (SX)',
4, 'Share',
5, 'S/Row-X (SSX)',
6, 'Exclusive',
(SELECT TO_CHAR (lmode) FROM v$lock l WHERE l.id1 = v.object_id)) mode_held
FROM v$locked_object v
, dba_objects d
, v$session s
WHERE v.object_id = d.object_id
AND v.session_id = s.sid
--and D.OBJECT_NAME='CB_CYCLE_SERVICE_CHARGES'
ORDER BY oracle_username, session_id;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment