If a lock wait occurs when querying the lock table in oracle and unlocking the table, we may want to know who has locked the table and who has waited. The following statement can be used to query who has locked the table: www.2cto.com SELECT/* + rule */s. username, decode (l. type, 'TT', 'table lock', 'tx ', 'row lock', NULL) LOCK_LEVEL, o. owner, o. object_name, o. object_type, s. sid, s. serial #, s. terminal, s. machine, s. program, s. osuser FROM v $ session s, v $ lock l, dba_objects o WHERE l. sid = s. sid AND l. id1 = o. object_id (+) AND s. the statement below username is not null can query who is waiting: SELECT/* + rule */lpad ('', decode (l. xidusn, 0, 3, 0) | l. oracle_username User_name, o. owner, o. object_name, o. object_type, s. sid, s. serial # FROM v $ locked_object l, dba_objects o, v $ session s WHERE l. object_id = o. object_id AND l. session_id = s. sid order by o. object_id, xidusn desc unlock command: alter system kill session 'sid, serial #'