Transaction-Record Lock
2019-08-26 19:55:11 0 举报
SQL
作者其他创作
大纲/内容
Transaction B\"Insert new accounts\"
COMMIT;
START TRANSACTION;SELECT * FROM account;+----+------------+---------+| id | account_id | balance |+----+------------+---------+| 1 | 1 | 800 || 4 | 2 | 2700 |+----+------------+---------+SELECT * FROM account WHERE account_id = 1 FOR UPDATE;+----+------------+---------+| id | account_id | balance |+----+------------+---------+| 1 | 1 | 800 |+----+------------+---------+COMMIT;
START TRANSACTION;
X lock of account_id 1
Time Line
Transaction A\"Record lock on account_id\"
unlock all
SELECT * FROM account;+----+------------+---------+| id | account_id | balance |+----+------------+---------+| 1 | 1 | 800 || 4 | 2 | 2700 || 9 | 3 | 2000 || 12 | 4 | 2000 |+----+------------+---------+
locked
0 条评论
下一页