Colleagues in the test library on a table plus fields, prompting ORA-00054, resource busy. The lock on the Table object should not be released.
For a description of the Oracle lock, refer to:
Oracle lock mechanism
http://blog.csdn.net/tianlesoftware/article/details/4696896
Use the following SQL to look at the locking of related objects in the system:
[SQL]View PlainCopy
- <pre name="code" class="SQL" >/* formatted on 2012/2/13 14:24:32 (QP5 v5.185.11230.41888) */ /c5>
- SELECT S.sid session_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, ' Exclusive ',
- 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, ' Exclusive ',
- To_char (REQUEST))
- Mode_requested,
- O.owner | | '. ' | | O.object_name | | ' (' | | O.object_type | | ') '
- as object_name,
- S.type Lock_type,
- L.id1 Lock_id1,
- L.id2 Lock_id2
- From V$lock L, SYS. Dba_objects O, V$session S
- WHERE l.sid = s.sid and l.id1 = o.object_id and object_name = ' xxxx ';</pre><br>
The SQL shows the lock on all objects, if you want to find a specific object, you can filter according to the object_name field, find the corresponding SID and then check the V$session view.
This view displays the information for the session, including the terminal information, and if the terminal is found, it can be submitted or rolled back to OK. I'm here to test the environment and kill the session directly. Then modify the table to be OK.
[SQL]View PlainCopy
- sql>alter system kill session ' sid,serial# '
Later, the test found that the above script sometimes can not find the relevant records of the object, so added the V$access view, through the view of the object to judge, after the modified script as follows:
[SQL]View PlainCopy
- SELECT S.sid session_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, ' Exclusive ',
- 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, ' Exclusive ',
- To_char (REQUEST))
- Mode_requested,
- O.owner | | '. ' | | O.object_name | | ' (' | | O.object_type | | ') '
- as object_name,
- S.type Lock_type,
- L.id1 Lock_id1,
- L.id2 Lock_id2
- From V$lock L, SYS. Dba_objects O, v$session s,v$access A
- WHERE l.sid = s.sid and l.id1 = o.object_id and s.sid=a.sid and a.object= ' proc_validate_rule_v3 ';
Once again, add the V$sql view, so that you can find the specific result of this kind of lock SQL statement, a one-time fix, SQL as follows:
[SQL]View PlainCopy
- /* Formatted on 2012/6/6 10:59:49 (QP5 v5.185.11230.41888) */
- SELECT distinct s.sid session_id,
- S.status,
- S.username,
- DECODE (Lmode,
- 0, ' None ',
- 1, ' Null ',
- 2, ' Row-s (SS) ',
- 3, ' Row-x (SX) ',
- 4, ' Share ',
- 5, ' S/row-x (SSX) ',
- 6, ' Exclusive ',
- 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, ' Exclusive ',
- To_char (REQUEST))
- Mode_requested,
- O.owner | | '. ' | | O.object_name | | ' (' | | O.object_type | | ') '
- as object_name,
- S.type Lock_type,
- L.id1 Lock_id1,
- L.id2 Lock_id2,
- S2. Sql_text
- From V$lock L,
- SYS. Dba_objects O,
- V$session S,
- V$access A,
- V$sql S2
- WHERE l.sid = S.sid
- and l.id1 = o.object_id
- and S.sid = A.sid
- and S2. Hash_value = S.sql_hash_value
- and a.object = ' Proc_validate_rule_v3 ';
The effect is as follows:
Ext.: http://blog.csdn.net/tianlesoftware/article/details/6822321
Oracle View Object Hold lock condition