mysql> show variables like “tx%”;
+—————+—————–+
| Variable_name | Value |
+—————+—————–+
| tx_isolation | REPEATABLE-READ |
+—————+—————–+
1 row in set (0.00 sec)
A B
select A = 100
start transaction
update record A set 111
select A = 111
update record A set 122
select A = 111
update A = 333
select A = 122
update record A set 111
block
commit
unblock
select A = 111
==============================================================
select A = 100
select B = 100
select C = 100
start transaction
update record A set 122
select A = 100
select B = 100
select C = 100
select A for update = 122
update record A set 122
block
commit
unblock
select A = 122
==============================================================
select A = 100
select B = 100
select C = 100
start transaction
update A = 333 //非索引
update record B set 122
block //全表被锁
commit
unblock
==============================================================
select A = 100
select B = 100
select C = 100
start transaction
update A = 333 //索引
update record B set 122 //记录级锁
select B = 122
insert D=101
select * for update
a/b/c/d
insert E=101
block
commit