SQL Server lock

Source: Internet
Author: User

From: http://topic.csdn.net/t/20061127/12/5187714.html

Lock prompt description
Holdlock retains the shared lock until the transaction is completed, instead of in the corresponding table, row, or Data Release the lock immediately when the page is no longer needed. Holdlock is equivalent to serializable.
Do not issue a shared lock or provide an exclusive lock. When this option is enabled, it may read uncommitted transactions or a group of pages that are rolled back during reading. Dirty reads may occur. Only Application In the SELECT statement.
Paglock usually uses the page lock where a single table lock is used.
Readcommitted performs scanning with the same lock semantics as transactions running at the committed read isolation level. By default, SQL Server 2000 operates at this isolation level.
Readpast skips the lock row. This option causes the transaction to skip the rows locked by other transactions (these rows are usually displayed in the result set), rather than blocking the transaction, wait for other transactions to release the locks on these rows. The readpast lock prompt is only applicable to transactions that run at the committed read isolation level and read only after the row-Level Lock. Only applicable to select statements.
Readuncommitted is equivalent to nolock.
Repeatableread performs scanning with the same lock semantics as transactions running at the repeatableread isolation level.
Rowlock uses row-level locks instead of coarse-grained page-level locks and table-level locks.
Serializable performs scanning with the same lock semantics as transactions running at the serializable read isolation level. Equivalent to holdlock.
Tablock uses table locks instead of finer-grained row-level locks or page-level locks. Before the statement ends, SQL Server keeps holding the lock. However, if both holdlock is specified, the lock will be held until the transaction ends.
Tablockx uses the table's exclusive lock. This lock prevents other transactions from reading or updating tables and holding them until the statement or transaction ends.
Updlock uses the update lock when reading the table, instead of the shared lock, and keeps the lock until the statement or transaction ends. Updlock allows you to read data (without blocking other transactions) and update data later. It also ensures that the data has not been changed since the last read.
Xlock uses the exclusive lock and remains until the end of the transaction on all data processed by the statement. You can use paglock or tablock to specify the lock. In this case, the exclusive lock applies to an appropriate level of granularity.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.