Home > Database > Mysql Tutorial > body text

How to share read lock in mysql

王林
Release: 2023-05-28 16:52:06
forward
1013 people have browsed it

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)
Copy after login

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!

Related labels:
source:yisu.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!