select * from xx where id = ‘xxx' for update 加入xxx不存在,会不会锁住某个区间

解决方案 »

  1.   

    根据你的表的存储引擎而定。myisam 是表锁
    innodb 可以支持行锁。
      

  2.   

    假设是innodb id是主键  无lock
      

  3.   

    是innodb我select一个不存在的记录,会锁住同个索引区间的其他记录么?如果会是x还是s锁
      

  4.   


    select * from tbname where id>100 for update;
    这样大于100的区间,全部锁定。不管有没有记录存在。