Concurrency control and locking is a mechanism used by DBMS to ensure that database transactions are executed in a safe manner. Atomicity, consistency, and isolation are achieved through concurrency control and locking. See ACID Model.
When data is accessed from more than one transaction concurrently, it is usually necessary to ensure that only one transaction at a time can change a data item. Locking is a way to do this. Because of locking, all changes to a particular data item will be made in the correct order in a transaction. See Isolation.
The following types of locking are usually distinguished: