Lock a table of the database

xiaoxiao2021-03-19  189

Lock a table of the database

Select * from Table with other transactions can read tables, but cannot update delete

Select * from Table with other transactions cannot read tables, updates, and delete

The "Plock Options" in the SELECT statement indicates that SQL Server provides a powerful and complete lock mechanism to help implement concurrency and high performance of the database system. Users can use the default settings of SQL Server to use Unlock Options in the SELECT statement to implement the expected results. This article describes the "lock options" in the SELECT statement and the corresponding function description. Function Description: NOLOCK (Unlocked) This option is selected, and SQL Server does not add any lock when reading or modifying data. In this case, the user is likely to read data in uncommit transaction or roll back, so-called "dirty data".

Holdlock This option is selected, and SQL Server keeps this shared lock to the end of the transaction without release of the way.

UPDLOCK This option is selected, SQL Server uses a modified lock when reading data instead of shared lock and keeps this lock to the end of the transaction or command. Using this option ensures that multiple processes can simultaneously read data but only the process can modify data.

Tablock This option is selected, and the SQL Server will share the lock until the command ends through the command. This option guarantees that other processes can only read and cannot modify data.

PAGLOCK This option is the default option, and SQL Server uses a shared page lock when selected.

Tablockx (Strong Table Lock) This option is selected, and SQL Server will arrange it to lock the lock until the command or transaction ends. This will prevent other processes from reading or modifying the data in the table.

Reference: http://community.9cbs.net/expert/topic/3359/3359873.xml? Temp = .9983332HTTP: //Community.9cbs.net/expert/topic/3382/3382022.xml? Temp = .5168726

转载请注明原文地址:https://www.9cbs.com/read-130056.html

New Post(0)