Types of Record Locking

Types Of Record Locking: Record locking can be defined as two types

  1. Shared Locks
  2. Exclusive Locks

Shared Locks

Shared Locks are also called Read Locks. When shared lock is applied by a transaction, other user of transaction can read data but not update the locked records. Shared locks are applied in case when you want to open same records for reading such that no other user changes these records during this time. Other transaction can also apply shared locks but no exclusive locks on these records.

Exclusive Locks

Exclusive locks are also called Write Locks. In case of exclusive locking, other transactions cannot be read or update the locked records. Exclusive locks is applied in situations when you want to change or update records during this time. Other transaction cannot apply any type of locks on exclusively locked records.

Noted that the locks are applied for short time only as other users are restricted for certain operations during this time. Record  locking mostly occurs when two or more transaction of different types functioning at the same time for two different purposes. It mostly damages the database