Get the App
SLTechnology News&Howtos  ›  Database  › 

SqlServer Series Notes-Lock

Shulou Source: shulou.com Published: 2022-06-01 11:22:42 11月13日 Update

In the database

Modify delete add x lock exclusive lock another operation cannot be accessed when the current table is modified

Query s lock shared lock

Debugging another command fails during a transaction rollback

Begin tran

Update student set name='jack' where id=1

Rollback tran

Select * from student with (nolock)

The database itself has a query to see if the current system has a deadlock that will sacrifice one request to satisfy another.

Avoid deadlocks in development:

1 the order of the operation tables in SQL must be as consistent as possible

2. Add with (nolock) to the query sql

3, deadlock caused by too many links (join) using temporary tables

Let an original table join query with temporary table-temporary table-original table 2 join query-temporary table-original 3

Tags: Query original deadlock data database consistency transaction command time system process link sequence development sacrifice notes Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Microsoft vpn Shulou Tech Info Huawei Linux