1. 程式人生 > >MySQL行鎖、表鎖

MySQL行鎖、表鎖

一、SELECT   FOR UPDATE

二、使用InnoDB引擎

三、Row-Level Lock 明確的的主鍵

1.select * from user where id = 1 for update; 明確指定主鍵並且有結果集。

2.select * from user where id = 0 for update; 明確指定主鍵並且無結果集。

四、Table-Level Lock無明確的主鍵

1.select * from user where name =’lai’ for update; 無主鍵,表鎖。

2.select * from user where id <> 66

3.select * from user where id like 66