是不是需要下面这样使用事务加上排他锁?
select counter from example for update;
update example set counter=counter+1;
是不是需要下面这样使用事务加上排他锁?
select counter from example for update;
update example set counter=counter+1;
4 回答1.5k 阅读✓ 已解决
8 回答1.3k 阅读
3 回答1.1k 阅读✓ 已解决
3 回答893 阅读✓ 已解决
2 回答1.8k 阅读
2 回答1.6k 阅读
1 回答890 阅读✓ 已解决
mysql默认事务隔离级别Repeatable Read下,update语句如果没指定id或唯一索引本身就会锁表,否则锁行,所以不需要显示加锁的。