Home  >  Article  >  php教程  >  SQL Server lock type

SQL Server lock type

高洛峰
高洛峰Original
2016-11-23 14:29:591195browse

(1) HOLDLOCK: Keep the shared lock on the table until the entire transaction ends, instead of releasing the added lock immediately after the statement is executed.

(2) NOLOCK: Do not add shared locks and exclusive locks. When this option takes effect, uncommitted read data or "dirty data" may be read. This option only applies to SELECT statements. ​

(3) PAGLOCK: Specify to add a page lock (otherwise a table lock may usually be added). ​​

(4) READCOMMITTED performs the scan with the same lock semantics as a transaction running at the read-commit isolation level. By default, SQL Server 2000 operates at this isolation level.

(5) READPAST: Skip locked data rows. This option will cause the transaction to skip data rows that have been locked by other transactions when reading data, instead of blocking until other transactions release the lock. READPAST only applies to SELECT statement operation in transaction operation under READ COMMITTED isolation level.​ ​

(6) READUNCOMMITTED: Equivalent to NOLOCK. ​​

(7) REPEATABLEREAD: Set the transaction to the repeatable read isolation level. ​​

(8) ROWLOCK: Use row-level locks instead of coarser-grained page-level locks and table-level locks.​ ​​

(9) SERIALIZABLE: Perform scans with the same lock semantics as transactions running at the serializable read isolation level. Equivalent to HOLDLOCK.

(10) TABLOCK: Specify the use of table-level locks instead of row-level or page-level locks. SQL Server releases this lock after the statement is executed. If HOLDLOCK is also specified, the lock will be maintained until this transaction. Finish.

(11) TABLOCKX: Specify the use of an exclusive lock on the table. This lock can prevent other transactions from reading or updating data in this table until the statement or the entire transaction ends.

(12) UPDLOCK: Specifies to set an update lock (update lock) instead of setting a shared lock when reading data in the table. The lock is maintained until the end of this statement or the entire transaction. The function of using UPDLOCK is to allow the user to read the data first ( and does not block other users from reading data), and ensures that when the data is updated later, the data has not been modified by other users during this period of time.


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn