行級鎖
可以用select * from table where aa=bb for update;
表級鎖
lock table table_name
需要注意的是select * ..for update 會對所有返回的行加鎖。單其他記錄是可以只查詢這些行的。
所以 要想起到真真加鎖機制,做操作時select都要 加上for update
行級鎖
可以用select * from table where aa=bb for update;
表級鎖
lock table table_name
需要注意的是select * ..for update 會對所有返回的行加鎖。單其他記錄是可以只查詢這些行的。
所以 要想起到真真加鎖機制,做操作時select都要 加上for update