The locking technique uses a lock that guarantees the exclusive use of data of transactions. The lock is used to restrict different transaction which is executing at the same time.
There are 3 phases of Locking technique
- Taking the lock control and accessing the data of the transaction
- Complete the transaction execution
- Release lock
There are two types of lock available in this protocol
- Shared lock: It is also represented by ‘lock-S’, and allows only to read the data from the transaction.
- Exclusive lock: It is also represented by ‘lock-X, and allows both the read and write operation to the data from the transaction.
2-phase locking technique
It is the same as the Locking technique explained above but it has two phases to act which are:
- Growing phase: It is a phase where a transaction acquires the lock but does not release it.
- Shrinking phase: It is a phase where a transaction releases the lock but does not acquire it.
The 2-phase locking technique is further divided into 3 categories
- Strict 2 phase locking
- Rigorous 2 phase locking
- Conservative 2 phase locking
Strict 2 phase locking
This locking technique satisfies the basic 2 phase locking but holds all the exclusive locks until the transaction is committed or aborted during the execution.
Rigorous 2 phase locking
This locking technique satisfies the basic 2 phase locking but holds all the exclusive locks and shared locks until the transaction is committed or aborted during the execution.
Conservative 2 phase locking
It is a locking technique that satisfies the basic 2 phase locking but it holds all the required locks at the beginning of transaction execution.
Rigorous two-phase locking is stricter than any of the available categories but it is very easy to implement. It ensures Cascadeless and strict recovery.
Rigorous 2 phase locking | Strict 2 phase locking | Conservative 2 phase locking |
It locks the exclusive and shared locks until the transaction gets committed or aborted | It locks the exclusive locks only until the transaction gets committed or aborted | It acquires all the locks required for the transaction at the beginning of transaction execution. |
It is easy to implement. | It is complex to implement. | It is not practically not possible. |
It does not have any growing phase but has shrinking phase. | It does not have any growing phase but has shrinking phase. | It may have any growing phase but no shrinking phase |
It is not deadlock-free. | It is not deadlock-free. | It is deadlock-free. |
It is stricter than strict and conservative 2 phase locking | It is stricter than basic locking techniques. | It is practically not possible. |
Similar Reads
-
Aggregate function in SQL with Examples
In a Database Management System (DBMS), an aggregate function is a special tool that performs calculations on a set of… -
SQL and Parts of SQL language
SQL is a popular programming language, which is used to manage the relational databases and to perform various operations on… -
Views in Relational Algebra
In SQL, virtual table are considered as views. Like Tables, views also contain rows and columns. We can select the… -
Syntax of following SQL commands: sysdate, to date(), dual table ,to_number, substr() and initcap()
1. SYSDATE Purpose: SYSDATE is a function that returns the current date and time of the database server. Syntax SELECT… -
What is Super key, Candidate key and Primary key?
1. Super Key A super key is an attribute or a set of attributes within a table that uniquely identifies… -
What is Cursor? Difference between Implicit and Explicit Cursor
A Cursor is essentially a temporary work area created in the system memory that comes into play during the execution… -
What is Relational Algebra?
Relational algebra is a formal language used to query and manipulate data stored in relational database systems. It provides a… -
What do you mean by Relational Model? Explain with Example
The relational model is a type of model, which represents how the data are stored in a relational database. In… -
Functions of DBA in DBMS
The role of a Database Administrator (DBA) is to manage and maintain the performance, security, and integrity of a database.… -
What is Data Abstraction and Data Redundancy in DBMS
In the world of data management, two terms often come up: data abstraction and data redundancy. Both play crucial roles…