mysql对表加锁和解锁实验
可以看出,当锁第二个表时,第一个表就解锁了
mysql> lock table abcc write;
Query OK, 0 rows affected (0.00 sec)
mysql> show OPEN TABLES where In_use > 0;
+----------+-------+--------+-------------+
| Database | Table | In_use | Name_locked |
+----------+-------+--------+-------------+
| tstdb | abcc | 1 | 0 |
+----------+-------+--------+-------------+
1 row in set (0.00 sec)
mysql> lock table abcc_usage write;
Query OK, 0 rows affected (0.00 sec)
mysql> show OPEN TABLES where In_use > 0;
+----------+-------------+--------+-------------+
| Database | Table | In_use | Name_locked |
+----------+-------------+--------+-------------+
| tstdb | abcc_usage | 1 | 0 |
+----------+-------------+--------+-------------+
1 row in set (0.00 sec)
mysql> unlock tables;
Query OK, 0 rows affected (0.00 sec)
mysql> show OPEN TABLES where In_use > 0;
Empty set (0.00 sec)