Oracle view the lock held by the object
My colleague added a field to a table in the test database, prompting ORA-00054, resource busy. The table object lock is not released.
Use the following SQL statement to check the locking status of related objects in the system:
- /* FormattedOn14:45:46 (QP5 v5.163.1008.3004 )*/
- SELECTS. SIDSESSION_ID,
- S. USERNAME,
- DECODE (LMODE,
- 0,'None',
- 1,'Null',
- 2,'Row-S (SS )',
- 3,'Row-X (SX )',
- 4,'Share',
- 5,'S/Row-X (SSX )',
- 6,'Exclusion',
- TO_CHAR (LMODE ))
- MODE_HELD,
- DECODE (REQUEST,
- 0,'None',
- 1,'Null',
- 2,'Row-S (SS )',
- 3,'Row-X (SX )',
- 4,'Share',
- 5,'S/Row-X (SSX )',
- 6,'Exclusion',
- TO_CHAR (REQUEST ))
- MODE_REQUESTED,
- O. OWNER |'.'| O. OBJECT_NAME |'('| O. OBJECT_TYPE |')' AsOBJECT_NAME,
- S. TYPELOCK_TYPE,
- L. ID1LOCK_ID1,
- L. ID2LOCK_ID2
- FROMV $ lock l, SYS. DBA_OBJECTSO, V $ SESSION S
- WHEREL. SID = S. SIDANDL. ID1 = O. OBJECT_ID
This SQL statement displays the locks on all objects. If you want to query a specific object, you can perform Filtering Based on the OBJECT_NAME field. Find the corresponding SID and check the V $ SESSION view.
This view displays the session information, including terminal information. If a terminal is found, it can be submitted or rolled back. I am in the test environment and kill the session directly. Then modify the table.
- SQL>AlterSystem kill session'Sid, SERIAL #'