Locks are the mechanisms used to prevent
destructive interaction between users accessing same resource simultaneously.
Locks provides high degree of data concurrency.
TYPES
Row level locks
Table level locks
ROW LEVEL LOCKS
In the row level lock a row is locked
exclusively so that other cannot modify the row until the transaction holding
the lock is committed or rolled back. This can be done by using select..for
update clause.
Ex:
SQL> select * from emp where sal > 3000 for update of comm.;
TABLE LEVEL LOCKS
A table level lock will protect table data
thereby guaranteeing data integrity when data is being accessed concurrently by
multiple users. A table lock can be held in several modes.
Share lock
Share update lock
Exclusive lock
SHARE LOCK
A share lock locks the table allowing other
users to only query but not insert, update or delete rows in a table. Multiple
users can place share locks on the same resource at the same time.
Ex:
SQL> lock table emp in share mode;
0 comments:
Post a Comment