間隙鎖

如何鎖定一行?
begin;
select * from tableName where a=? for update;
// 要進行的操作。。。。。。。
commit;
- 在鎖定某一行後,其他使用者操作會被阻塞,直到鎖定行的會話送出commit
行鎖總結:
行鎖分析:
優化建議:
頁鎖
- 開鎖和加鎖時間介于表鎖和行鎖之間;會出現死鎖;鎖定粒度在表鎖和行鎖之間,并發度一般
begin;
select * from tableName where a=? for update;
// 要進行的操作。。。。。。。
commit;
行鎖分析:
優化建議: