第 9 章 · 上机四
LOCK TABLES account WRITE
A 把整张表独占了,B 连读都读不动。
窗口 A
Welcome to the MySQL monitor. Commands end with ;
Server version: 8.0.36 MySQL Community Server - GPL
上下两扇窗口是同一台服务器上的两个会话。拿不到锁的那句会卡住,等对方放手才接着跑。
mysql>
窗口 B
Welcome to the MySQL monitor. Commands end with ;
Server version: 8.0.36 MySQL Community Server - GPL
mysql>
这一句敲进窗口 A
重 点
WRITE 锁是排它锁,拿着它自己读写都行,别人什么也干不了。
关键术语
排它
锁
Ex
c
独占
一