ERROR 1100 (HY000): Table '表名' was not locked with LOCK TABLES (表被锁定)

ERROR 1100 (HY000): Table 'stu' was not locked with LOCK TABLES

表被锁定无法进行增删改查的操作可以使用unlock tables;命令进行解锁之后就可以进行正常操作了。

mysql> select * from stu where class_id =1 or sname like '%张%'
    -> ;
ERROR 1100 (HY000): Table 'stu' was not locked with LOCK TABLES
mysql> unlock stu;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'stu' at line 1
mysql> unlock tables;
Query OK, 0 rows affected (0.00 sec)

mysql> select * from stu;
+----+--------+----------+---------------------+---------------------+------+
| id | sname  | class_id | birthday            | updated_at          | sex  |
+----+--------+----------+---------------------+---------------------+------+
|  1 | 李广   |        1 | 1998-02-12 08:22:13 | 2019-07-20 14:22:16 | 男   |
|  2 | 何青   |        1 | 1985-07-22 18:19:13 | 2019-07-17 21:50:38 | 女   |
|  3 | 钱佳   |        3 | 1989-11-17 10:29:13 | 2019-07-17 20:54:14 | 男   |
|  4 | 刘玉   |        1 | 1999-07-03 19:46:13 | 2019-07-17 20:54:14 | 女   |
|  5 | 后盾人 |        2 | 2003-09-01 20:33:13 | 2019-07-20 16:41:32 | 男   |
|  6 | 张云   |        3 | 1996-09-01 20:33:13 | 2019-07-19 12:59:40 | 女   |
|  7 | 李风   |        1 | 2003-02-15 20:33:13 | 2019-07-20 14:30:02 | 男   |
|  8 | 李兰   |        2 | NULL                | 2019-07-19 12:50:07 | 女   |
|  9 | 李月   |        1 | NULL                | 2019-07-18 17:49:03 | 女   |
| 10 | 刘雷   |     NULL | 1996-11-08 20:33:13 | 2019-07-20 15:59:28 | NULL |
+----+--------+----------+---------------------+---------------------+------+
10 rows in set (0.07 sec)

 

你可能感兴趣的:(错误,数据库)