SqlServer Series Notes-Lock
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