MySQL テーブルのロック
Rev.1を表示中。最新版はこちら。
表1 READロック時の挙動
No. | スレッドA | スレッドB |
---|---|---|
1 | mysql> select id,name from friends; +----+--------+ | id | name | +----+--------+ | 2 | tomita | +----+--------+ 1 row in set (0.00 sec) | mysql> select id,name from friends; +----+--------+ | id | name | +----+--------+ | 2 | tomita | +----+--------+ 1 row in set (0.00 sec) |
2 | mysql> LOCK TABLES friends READ; Query OK, 0 rows affected (0.00 sec) | |
3 | mysql> select id,name from friends; +----+--------+ | id | name | +----+--------+ | 2 | tomita | +----+--------+ 1 row in set (0.00 sec) | |
4 | mysql> UPDATE friends SET address="Yokohama" WHERE id=2; | |
5 | mysql> UNLOCK TABLES; Query OK, 0 rows affected (0.00 sec) | Query OK, 1 row affected (51.73 sec) Rows matched: 1 Changed: 1 Warnings: 0 |