简介
本文对RR事务隔离级别下的select语句进行加锁处理分析。
表结构如下:
mysql> show create table lock_test\G
*************************** 1. row ***************************
Table: lock_test
Create Table: CREATE TABLE `lock_test` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`age` int(11) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `age` (`age`)
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb4
1 row in set (0.00 sec)
表中数据
mysql> select * from lock_test;
+----+------+
| id | age |
+----+------+
| 2 | 5 |
| 3 | 10 |
| 4 | 20 |
| 5 | 30 |
| 7 | 30 |
+----+------+
5 rows in set (0.00 sec)