Quick Search:
 
 Oracle PL/SQL: LOCKS: Table Locking Jump to:  
Category: >> Oracle PL/SQL >> LOCKS: Table Locking  

<< lastnext >>

Snippet Name: LOCKS: Table Locking

Description: The basic idea of locking is that when a user modifies data through a transaction, that data is locked by that transaction until the transaction is committed or rolled back. The lock is held until the transaction is complete - this known as data concurrency.

The second purpose of locking is to ensure that all processes can always access (read) the original data as they were at the time the query began (uncommitted modification), This is known as read consistency.

Also see:
» LOCKS: View Locked Objects
» Display and release DBMS_LOCK locks
» Display locks and latches

Comment: (none)

Language: PL/SQL
Highlight Mode: PLSQL
Last Modified: March 13th, 2009

-- table locking
 
LOCK TABLE <table_name> IN <lock_mode>  
MODE [NOWAIT | WAIT <seconds>];
 
-- example: 
LOCK TABLE sales.server IN EXCLUSIVE MODE WAIT 60;
 
-- OR:
 
LOCK TABLE sales.server IN EXCLUSIVE MODE NOWAIT;
 
 
-- show active table locks:      
 
SELECT SUBSTR(a.object,1,25) TABLE_NAME,
SUBSTR(s.user_id,1,15) USER_ID,
SUBSTR(p.pid,1,5) PID,
SUBSTR(p.spid,1,10) SYSTEM_ID,
DECODE(l.TYPE,
  'RT','Redo Log Buffer',
  'TD','Dictionary',
  'TM','DML',
  'TS','Temp Segments',
  'TX','Transaction',
  'UL','User',
  'RW','Row Wait',
  l.TYPE) LOCK_TYPE
FROM gv$access a, gv$process p, gv$session s, gv$lock l
WHERE s.sid = a.sid
AND s.paddr = p.addr
AND l.sid = p.pid
GROUP BY a.object, s.user_id, p.pid, l.TYPE, p.spid
ORDER BY a.object, s.user_id;


 
   Home |    Search |    Code Library |    Sponsors |    Privacy |    Terms of Use |    Contact Us © 2003 - 2024 psoug.org