There are four types of locks:
Exclusive
prevents any other type of concurrent access
– Applies only to databases or tables, not rows.– Very restrictive
Write
prevents other Read, Write, Exclusive locks.
Read
prevents Write and Exclusive locks
Access
prevents Exclusive locks only.
Locks may be applied at three database levels:
Database
applies to all tables/views in the database.
Table/View
applies to all rows in the table/views.
Row Hash
applies to all rows with same row hash.
Lock types are automatically applied based on the SQL command:
SELECT—applies a Read lock.
UPDATE—applies a Write lock.
CREATE TABLE—applies an Exclusive lock.
Example : A new ACCESS lock request is granted immediately.
Advantages of Access locks:
•Permit quicker access to table in multi-user environment.
•Have minimal blocking effect on other queries.
•Very useful for aggregating large numbers of rows.
•Permit quicker access to table in multi-user environment.
•Have minimal blocking effect on other queries.
•Very useful for aggregating large numbers of rows.
Disadvantages of Access locks:
•May produce erroneous results if performed during table
maintenance.