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)
热门推荐
10 财运虎年祝福语简短语
11 单亲爸爸春节祝福语简短
12 狗狗上厕所训练
13 植物种植祝福语简短
14 翻译考试祝福语朋友简短
15 个人周年庆简短祝福语
16 狗狗怎么训练
17 分别祝福语简短搞笑英文
18 生日广州男生祝福语简短