Tuesday 11 October 2011

Locking in Oracle

{\rtf1\ansi\ansicpg1252\deff0\deflang16393{\fonttbl{\f0\froman\fprq2\fcharset0 Times New Roman;}{\f1\fnil\fcharset0 Calibri;}}
{\stylesheet{ Normal;}{\s1 heading 1;}{\s2 heading 2;}{\s3 heading 3;}{\s4 heading 4;}{\s5 heading 5;}}
{\*\generator Msftedit 5.41.21.2509;}\viewkind4\uc1\pard\li720\lang1033\f0\fs22 Locks are mechanisms that prevent destructive interaction between transactions accessing the same resource - either user objects (such as tables and rows) or system objects not visible to users (such as shared data structures in memory and data dictionary rows). In all cases, Oracle automatically obtains necessary locks when executing SQL statements, so users need not be concerned with such details. Oracle automatically uses the lowest applicable level of restrictive ness to provide the highest degree of data concurrency yet also provide fail-safe data integrity. Oracle also allows the user to lock data manually. \par
\pard\fi720 Oracle uses two modes of locking in a multi-user database:\par
\pard\li720\b Exclusive lock mode: \b0 Prevents the associates resource from being shared. This lock mode is obtained to modify data. The first transaction to lock a resource exclusively is the only transaction that can alter the resource until the exclusive lock is released. \~\par
\b Share lock mode: \b0 Allows the associated resource to be shared, depending on the operations involved. Multiple users reading data can share the data, holding share locks to prevent concurrent access by a writer (who needs an exclusive lock). Several transactions can acquire share locks on the same resource. \~\b \~\par
\pard\keepn\s5\li720 Types of Locks\par
\pard\li720\b0 Oracle automatically uses different types of locks to control concurrent access to data and to prevent destructive interaction between users. Oracle automatically locks a resource on behalf of a transaction to prevent other transactions from doing something also requiring exclusive access to the same resource. The lock is released automatically when some event occurs so that the transaction no longer requires the resource. \par
\b DML locks (data locks): \b0 DML locks protect data. For example, table locks lock entire tables, row locks lock-selected rows. \~\b \~\par
DDL locks (dictionary locks): \b0 DDL locks protect the structure of schema objects - for example, the definitions of tables and views. \~\par
\b Internal locks and latches: \b0 Internal locks and latches protect internal database structures such as datafiles. Internal locks and latches are entirely automatic. \~\b \~\par
Distributed locks: \b0 Distributed locks ensure that the data and other resources distributed among the various instances of an Oracle Parallel Server remain consistent. Distributed locks are held by instances rather than transactions. They communicate the current status of a resource among the instances of an Oracle Parallel Server. \~\b \~\par
Parallel cache management (PCM) locks: \b0 Parallel cache management locks are distributed locks that cover one or more data blocks (table or index blocks) in the buffer cache. PCM locks do not lock any rows on behalf of transactions. \~\b \b0\~\b\par
\pard\fs24\par
\pard\sa200\sl276\slmult1\lang9\b0\f1\fs22\par
}

No comments:

Post a Comment