Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

[learning] SQL Basics-012-Lock

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

1. Type

Exclusive locks: record, row level

Shared locks: table level, preventing table structure from being modified using DDL

Shared lock [S lock]

Also known as read lock, if transaction T adds an S lock to the data object A, transaction T can read A but cannot modify A. other transactions can only add S lock to An instead of X lock until T releases the S lock on A. This ensures that other transactions can read A, but no modifications can be made to A until T releases the S lock on A.

Exclusive lock [X lock]

Also known as write lock. If transaction T adds an X lock to the data object A, transaction T can read An or modify A, and other transactions can no longer lock A until T releases the lock on A. This ensures that other transactions cannot read and modify A until T releases the lock on A.

2 、 select for update

Select * from emp for update; returns the result after waiting for row lock to be released

Manual lock protection to lock only specified row records

Select for update nowait returns an error if it is locked

3. Deadlock

Popular explanation: an is waiting for the resource release of B, and B is waiting for the resource release of A.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report