说明
1、MyISAM表的读操作(添加读书锁)不会阻止其他过程对同一表的读操作,但会阻止同一表的写作操作。
2、只有读锁释放后,才能执行其他过程的写作操作。锁释放前不能取其他表。
实例
Transaction-A mysql> lock table myisam_lock read; Query OK, 0 rows affected (0.00 sec) mysql> select * from myisam_lock; 9 rows in set (0.00 sec) mysql> select * from innodb_lock; ERROR 1100 (HY000): Table 'innodb_lock' was not locked with LOCK TABLES mysql> update myisam_lock set v='1001' where k='1'; ERROR 1099 (HY000): Table 'myisam_lock' was locked with a READ lock and can't be updated mysql> unlock tables; Query OK, 0 rows affected (0.00 sec)
以上就是mysql中共享读锁的实现,希望对大家有所帮助。更多编程基础知识学习:
推荐操作系统:windows7系统、mysql5.8、DELL G3电脑