Home  >  Article  >  Database  >  How to share read lock in mysql

How to share read lock in mysql

王林
王林forward
2023-05-28 16:52:061031browse

Explanation

1. The read operation of the MyISAM table (adding a reading lock) will not prevent other processes from reading the same table, but it will prevent the writing operation of the same table.

2. Only after the read lock is released, writing operations of other processes can be performed. No other tables can be accessed before the lock is released.

Example

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)

The above is the detailed content of How to share read lock in mysql. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:yisu.com. If there is any infringement, please contact admin@php.cn delete