1. updlock
It 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. When we use updlock to read records, we can add an update lock to the obtained records, in this way, the lock record cannot be changed in other threads and can only be changed after the transaction of this thread ends.
2. rowlock
Rowlock tells SQL Server to only use row-level locks. The rowlock syntax can be used in select, update, and delete statements. If a specified primary key exists in the update statement, the row-Level Lock is always triggered.
3. nolock
Nolock can ignore the lock and directly read data from the database. This means that the lock can be avoided to improve performance and scalability. But it also meansCodeThe possibility of an error exists. You may read uncommitted data that is being processed by the running transaction without verification. This risk can be quantified.
SQL Server supports more types of locks, such as tablock. SQL Server uses row-level locks, but often expands to page locks and table locks, resulting in deadlocks. In practical applications, you need to consider the concurrency of SQL operations, real-time requirements, table indexes, data distribution modes, and so on. Each lock type has its most suitable scenarios.
You can use management ---> activity monitor to analyze the lock snapshot information in the database.You can use the DBCC command to write lock-related information to the SQL server log for monitoring.
The following strange phenomena may occur in the process in the sushortded state:Http://www.windows-tech.info/15/fd219330fa8cb37a.php