In my work I have to load data into Oracle databases very frequently. Doing this kind of operations can lead to locking database objects. A table lock can cause a lot of delays because while a table is locked you can’t delete/insert/update entries in it….
So here’s how to find what objects are locked in a DB. You need sysdba access to run this:
SELECT a.sid , a.serial# , a.username , c.os_user_name , a.program , a.logon_time , a.machine , a.terminal , b.object_id , substr(b.object_name,1,40) object_name , DECODE(c.locked_mode, 1, 'No Lock', 2, 'Row Share', 3, 'Row Exclusive', 4, 'Shared Table', 5, 'Shared Row Exclusive', 6, 'Exclusive') locked_mode from v$session a , dba_objects b , v$locked_object c where a.sid = c.session_id and b.object_id = c.object_id
And once you have identified the offending session (the one locking the table you are working on), here’s how to kill the session so the table is unlocked:
ALTER SYSTEM KILL SESSION 'sid,serial#';
Of course, you’ll need to substitute “sid” and “serial#” with the information from the first query.