Concepts of oracle locks-1. Locks 1. The concept of locks: a database is a shared resource used by multiple users. When multiple users concurrently access data, multiple transactions can simultaneously access the same data in the database. If such concurrent operations are not controlled, incorrect data may be read and stored, compromising data consistency. Locking is a very important technology for implementing database concurrency control. Before a transaction operates on a data object, it first sends a request to the system and locks it, after the lock, the transaction has certain control over the object. Before the transaction releases the lock, other transactions cannot operate on the data object. In oracle databases, it does not apply a lock to a table or several rows. A lock exists as an attribute of a data block. That is to say, each data block stores the data information in its own data block, which is called the ITL (Interested Transaction List). Any Transaction that has activity on this data block, its information will be recorded in it for subsequent operation queries to ensure transaction consistency. 2. Category of Locks: user-specific a) and Automatic Locks: When performing a database operation, by default, the system automatically acquires all necessary locks for this database operation. Automatic locks are divided into DML locks, DDL locks, and system locks. B) Manual Locks: in some cases, you need to display the data used to lock database operations to better execute database operations, the display lock is set by the user for the database object. Share lock (S): The share lock allows a transaction to share access to specific database resources. Another transaction can also access this resource or obtain the same share lock, the shared lock improves concurrency for transactions. B) exclusive lock (X): After an exclusive lock is set for a transaction, the transaction Obtains resources independently. Another transaction cannot obtain the shared or exclusive lock for the same object before committing the transaction. According to the control to a), DML lock: used to control data manipulation in concurrent transactions to ensure data consistency and integrity. DML lock is mainly used to protect data integrity in concurrent situations. It is also divided into: TX lock (transaction lock or row-Level Lock): TX lock mainly locks a row of records in a table. When Insert, update, delete, merge, select ...... For update, the system will automatically obtain the TX lock until the transaction commit or rollback can be used to transaction the lock. When a transaction acquires a row-Level Lock (TX lock), the transaction also obtains the table-Level Lock corresponding to the row. The table-Level Lock can block DDL operations to ensure data integrity. Tmlock: when a transaction is performing Insert, update, delete, merge, select ...... For update, the system automatically assigns a table-Level Lock (tmlock) to the transaction)