关于mysql 行锁

关于InnoDB 的行锁

一个窗口

start transaction;  -- 开启事务
select * from ams_attr_ex_values where id = 1 for update; -- 行锁
update ams_attr_ex_values set attr_ex_value = 62;

另一个窗口

start transaction;  -- 开启事务
select * from ams_attr_ex_values where id = 1 for update; -- 行锁
update ams_attr_ex_values set attr_ex_value = 63;

如果当第一个窗口事务不提交commit的话,会发现第二个窗口会一直停留在select *  如图所示

标题

 

posted @ 2022-01-25 18:06  树下水月  阅读(23)  评论(0编辑  收藏  举报