SQL> shutdown abort .com

About DBA Queries DBA Scripts Quick Guides Other Stuff Contact
Andy only 
 

dba_lock

Name              Type
----------------- -------------
SESSION_ID        NUMBER
LOCK_TYPE         VARCHAR2(26)
MODE_HELD         VARCHAR2(40)
MODE_REQUESTED    VARCHAR2(40)
LOCK_ID1          VARCHAR2(40)
LOCK_ID2          VARCHAR2(40)
LAST_CONVERT      NUMBER
BLOCKING_OTHERS   VARCHAR2(40)
DBA_LOCK lists all locks or latches held in the database, and all outstanding requests for a lock. To see this in action lets create a simple table put a couple of rows in it and then create a lock. Begin by creating a table and inserting a row into it (don't commit):
create table test_table (
	id number primary key
,	text varchar2(100)
)
/

insert into test_table values(1, 'hello');
If you then run the following query, you will see that you have a lock on the uncommitted row:
select	lock_type
,	mode_held
,	blocking_others
from 	dba_locks l
,	dba_objects o
where	l.lock_id1 = o.object_id
and	o.object_name = 'TEST_TABLE'
/

LOCK_TYPE    MODE_HELD  BLOCKING_OTHERS
------------ ---------- --------------------
DML          Row-X (SX) Not Blocking
As soon as you commit, the lock will disappear.


For more useful DBA queries click here.

Copyright© 2007-2012 Andrew Barry