Mysql中的并发事务

Mysql中的并发事务,mysql,database,transactions,Mysql,Database,Transactions,我有一个accounts表。帐户id 1的余额是550。假设mysql的一个连接正在这样做: START TRANSACTION; update accounts set balance = balance - 200 where id = 1 #TIME t update accounts set balance = balance + 200 where id = 2 #TIME t + 100 COMMIT START TRANSACTION; update accounts se

我有一个accounts表。帐户id 1的余额是550。假设mysql的一个连接正在这样做:

START TRANSACTION;
update accounts set balance = balance - 200 where id = 1 #TIME t 
update accounts set balance = balance + 200 where id = 2 #TIME t + 100  
COMMIT
START TRANSACTION;
update accounts set balance = balance - 100 where id = 1 and balance > 500 #TIME t  + 50 
COMMIT
现在假设另一个连接正在执行此操作:

START TRANSACTION;
update accounts set balance = balance - 200 where id = 1 #TIME t 
update accounts set balance = balance + 200 where id = 2 #TIME t + 100  
COMMIT
START TRANSACTION;
update accounts set balance = balance - 100 where id = 1 and balance > 500 #TIME t  + 50 
COMMIT

我想知道数据库的最终状态是什么以及为什么?

这取决于事务隔离级别的类型。@助记符:谢谢!我觉得这个视频很有趣。