oracle check table lock 1

oracle check table lock

select t2.username, t2.sid, t2.serial#, t3.object_name, t2.OSUSER, t2.MACHINE, t2.PROGRAM, t2.COMMAND, t2.LAST_CALL_ET
 from v$locked_object t1, v$session t2, dba_objects t3
 where t1.session_id = t2.sid and t1.object_id = t3.object_id
  ORDER BY t2.logon_time;

Here is what the above code is Doing:
1. It’s querying the v$locked_object view to get the object_id of the locked object.
2. It’s querying the v$session view to get the session_id of the session that is locking the object.
3. It’s querying the dba_objects view to get the name of the locked object.
4. It’s joining the results of the above three queries to get the username, sid, serial#, object_name, OSUSER, MACHINE, PROGRAM, COMMAND, and LAST_CALL_ET of the session that is locking the object.
5. It’s ordering the results by logon_time.

Similar Posts