需要启动2个事务

  1. Start Transaction;
  2. Begin;
  3. select * from t_stockset;
  4. update t_stockset price=1.56 where item='book';
  5. select * from t_stockset;
  6. commit;
第一个事务更新后,在没有commit前,第二个事务是无法更新的,其事务会等待。
第一个事务commit后,第二个事务运行完毕,此时第二个事务并没有commit,所以第一个事务读取到的还是它自己提交的数据
第二个事务提交后,2个事务都读取到的是第二个事务提交的数据了。
并发事务中的数据锁的例子

相关文章:

  • 2021-10-14
  • 2021-11-25
  • 2022-02-02
  • 2021-10-28
  • 2021-05-10
  • 2021-06-22
  • 2022-12-23
  • 2021-10-02
猜你喜欢
  • 2021-09-14
  • 2021-12-24
  • 2022-12-23
  • 2021-07-27
  • 2021-05-30
相关资源
相似解决方案