事务1
begin transaction
update t set count= count +1 where id=A
update t set count=cunt+1 where id=b
end transaction
事务2
begin transaction
update t set count= count +1 where id=B
update t set count= count +1 where id=A
end transaction
事务1
begin transaction
update t set count= count +1 where id=A
update t set count=cunt+1 where id=b
end transaction
事务2
begin transaction
update t set count= count +1 where id=B
update t set count= count +1 where id=A
end transaction
15 回答8.4k 阅读
8 回答6.2k 阅读
5 回答3.2k 阅读✓ 已解决
3 回答3.6k 阅读✓ 已解决
1 回答4k 阅读✓ 已解决
2 回答2.8k 阅读✓ 已解决
3 回答2.2k 阅读✓ 已解决
正确方式,进行将update语句更加id排序。比如永远先更新A,然后更新B