关于mysql锁机制,这个文章不错,链接:http://www.cnblogs.com/deliver/p/5730616.html
update的where 条件,必须覆盖索引,才会使用行锁,否则就是用表锁
update
where
update user set age = 33 where name = 'terry' and sex = 2 , 如果name 和sex是二维索引,则加的是行锁,否则是表锁
update user set age = 33 where name = 'terry' and sex = 2
name
sex
innode 的 行锁,要基于索引
where条件覆盖索引,行锁才能用
这是前提