MyIsam读锁语法:lock table table_name read;unlock tables;
当session1锁住了table1,那么只能对table1做查询操作,插入table1或其他表都报错,查寻其他表也报错,为table1取别名查询也报错,在session2中不影响查询,但增删改操作会阻塞
MyIsam写锁语法:lock table table_name write;unlock tables;
当session1锁住了table1,那么只能对table1进行操作。当session2对table1访问时,会被阻塞
InnoDB读锁语法:select * from table lock in share mode
InnoDB写锁语法:select * from table for update
InnoDB对于增删改操作,事务未提交前都是默认加了排他锁
