mysql> lock table user as a read, ip as b read, state as c read;
Query OK, 0 rows affected (0.00 sec)
mysql> select a.user_name,a.user_pass,b.user_ip,visi_date,c.value
-> from user a,ip b,state c
-> where a.user_name=share and b.user_ip=172.16.0.33
-> and a.user_name=b.user_name
-> and a.user_state=c.stat;
+-----------+-----------+-------------+------------+-------+
| user_name | user_pass | user_ip | visi_date | value |
+-----------+-----------+-------------+------------+-------+
| share | 111111 | 172.16.0.33 | 0000-00-00 | 正常 |
+-----------+-----------+-------------+------------+-------+
1 row in set (0.01 sec)。
可以通过检查table_locks_waited和table_locks_immediate状态变量来分析系统上的表锁定争夺。
mysql> show status like table%;
+-----------------------+-------+
| Variable_name | Value |
+-----------------------+-------+
| Table_locks_immediate | 27 |
| Table_locks_waited | 0 |
+-----------------------+-------+
2 rows in set (0.00 sec)