0% found this document useful (0 votes)
16 views2 pages

LOCK - Types - Levels

The document discusses locks in Oracle databases, which are mechanisms to ensure data integrity during SQL operations. It outlines two types of locks: shared locks for read operations and exclusive locks for write operations, along with their respective characteristics. Additionally, it describes the three levels of locking (row, page, and table) and provides syntax for locking tables in different modes.

Uploaded by

patelsoham.797
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views2 pages

LOCK - Types - Levels

The document discusses locks in Oracle databases, which are mechanisms to ensure data integrity during SQL operations. It outlines two types of locks: shared locks for read operations and exclusive locks for write operations, along with their respective characteristics. Additionally, it describes the three levels of locking (row, page, and table) and provides syntax for locking tables in different modes.

Uploaded by

patelsoham.797
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Unit - 4 (Indexes, Views and Security)

 Locks
 Definition :
 Locks are mechanism used to ensure data integrity. The oracle engine automatically
locks table data while executing SQL statements like Select/insert/UPDATE/DELETE. This
type of locking is called implicit locking
 Types of Locks
 There are two types of Locks
 Shared Lock
 Exclusive Lock
 Shared Lock
 Shared locks are placed on resources whenever a read operation (select) is performed.
 Multiple shared locks can be simultaneously set on a resource.
 Exclusive Locks
 Exclusive locks are placed on resources whenever a write operation (INSERT, UPDATE
And DELETE) are performed.
 Only one exclusive lock can be placed on a resource at a time.
 i.e. the first user who acquires an exclusive lock will continue to have the sole
ownership of the resource, and no other user can acquire an exclusive lock on that
resource
 Levels of Locks
 Oracle does not provide a field level lock.
 Oracle provides the following three levels of Locking.
 Row Level
 Page Level
 Table Level
 Row Level Locking
 If the WHERE clause evaluates to only one row in the table, a row level lock is used.
 Page Level Locking
 If the WHERE clause evaluates to a set of data, a page level lock is used.
 Table Level Locking
 If there is no WHERE clause, the query accesses the entire table, a table level lock is
used.
 Can't update entire table data when update is done by other user.
 Syntax: LOCK TABLE <table name> [<table name>]….. IN { ROW SHARE / ROW EXCLUSIVE /
SHARE UPDATE / SHARE / SHARE ROW EXCLUSIVE / EXCLUSIVE }[NOWAIT]
 Exclusive: They allow query on the locked resource but prohibit any other activity
 Syntax: Client A > Lock table client_master IN Exclusive Mode NOWAIT;
 Output Table(s) Locked.

You might also like