Quick Search:
CODE
Oracle PL/SQL Code Library
JOBS
Find Or Post Oracle Jobs
FORUM
Oracle Discussion & Chat
 Oracle PL/SQL: LOCKS: Table Locking Jump to:  
Category: >> Oracle PL/SQL >> LOCKS: Table Locking Bookmark and Share

<< 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;


Free
Oracle Magazine
Subscriptions
and Oracle White Papers


SQL University.net courses meet the most demanding needs of the business world for advanced education in a cost-effective manner. SQL University.net courses are available immediately for IT professionals and can be taken without disruption of your workplace schedule or processes.

Compared to traditional travel-based training, SQL University.net saves time and valuable corporate resources, allowing companies to do more with less. That's our mission, and that's what we deliver.

Click here to find out more
 
Home      :      Code Library      :      Sponsors      :      Privacy      :      Terms of Use      :      Contact Us 225 users online    © 2009 psoug.org

PSOUG LOGIN
Username: 
Password: 
Forgot your password?