MySQL错误ERROR 1099(HY000):表已被READ锁锁定,无法更新
要摆脱LOCKTABLES查询,您需要使用UNLOCKTABLES。
让我们创建一个表-
mysql> create table demo6 −> ( −> country_name varchar(100 −> ) −> );
借助insert命令将一些记录插入表中-
mysql> insert into demo6 values('US');
mysql> insert into demo6 values('UK');
mysql> insert into demo6 values('AUS');使用select语句显示表中的记录-
mysql> select *from demo6;
这将产生以下输出-
+--------------+ | country_name | +--------------+ | US | | UK | | AUS | +--------------+ 3 rows in set (0.00 sec)
在这里,我只有上表的锁可供读取运算符使用。以下是查询-
mysql> lock tables demo6 read;
以下是您尝试在上表中插入时的错误-
mysql> insert into demo6 values('IND');
ERROR 1099 (HY000): Table 'demo6' was locked with a READ lock and can't be updated如果您使用UNLOCKTABLES,则可以在同一表中插入记录-
mysql> UNLOCK TABLES;
借助insert命令将一些记录插入表中-
mysql> insert into demo6 values('IND');使用select语句显示表中的记录-
mysql> select *from demo6;
这将产生以下输出-
+--------------+ | country_name | +--------------+ | US | | UK | | AUS | | IND | +--------------+ 4 rows in set (0.00 sec)
热门推荐
1 如何训练狗狗握手
10 新员工寄语祝福语简短
11 新婚敬酒祝福语大全简短
12 怎么训练狗狗
13 训练狗狗上厕所
14 春蚕老师祝福语简短励志
15 高考好运如愿祝福语简短
16 战哥过年祝福语简短
17 中考感谢朋友祝福语简短
18 长沙旅游祝福语大全简短