Lock type for SQL Server database

Source: Internet
Author: User

SQL Server Lock:

1.HOLDLOCK: Keep the shared lock on the table until the entire transaction ends, rather than immediately releasing the added lock after the statement has been executed.

2. NOLOCK: Do not add shared and exclusive locks, when this option is in effect, may read UNCOMMITTED read data or "dirty data", this option applies only to select statements.

3. Paglock: Specifies to add a page lock (otherwise it is usually possible to add a table lock).

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

5. READPAST: Skipping data rows that have been locked, this option will enable transactions to read data while skipping data rows that have been locked by other transactions, rather than blocking until other transactions release the lock, READPAST only applies to read Committed the SELECT statement operation in a transaction operation under the isolation level.

6. ReadUncommitted: Equal to Nolock.

7. RepeatableRead: Sets the transaction to a repeatable read level of isolation.

8. Rowlock: Use row-level locks instead of coarser-grained page-level and table-level locks.

9. SERIALIZABLE: Scans are performed with the same lock semantics as transactions running at the serializable isolation level. Equal to HOLDLOCK. 10. TABLOCK: Specifies that a table-level lock is used instead of a row-level or page-level lock, which is released by SQL Server when the statement is executed, and if Holdlock is specified, the lock remains until the end of the transaction.

11. Tablockx: Specifies that exclusive locks are used on the table, which prevents other transactions from reading or updating data for this table until the statement or the entire transaction ends.

12. UPDLOCK: Specifies that the update lock is set when the data is read in the table instead of a shared lock, which is persisted to this statement or the end of the entire transaction, using UPDLOCK to allow the user to read the data first (and not to block other users from reading the data), and ensure that the data is not modified by other users for a period of time when the data is later updated.

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.