gpt4 book ai didi

mysql - 使用锁定/解锁更改表

转载 作者:行者123 更新时间:2023-11-30 23:34:26 25 4
gpt4 key购买 nike

有人可以解释为什么我会收到此错误:

Table 'last' was not locked with LOCK TABLES

这是一个接一个执行的查询:

LOCK TABLES last WRITE;
DELETE FROM last WHERE id < '30';
ALTER TABLE last DROP id;
ALTER TABLE last ADD COLUMN `id` SMALLINT(5) UNSIGNED NOT NULL AUTO_INCREMENT FIRST, ADD PRIMARY KEY (`id`);

UNLOCK TABLES;

错误点在添加列 (id) 的行上,但是如果我在删除之后放置解锁语句 - 一切正常,没有错误。我真的不能最后解锁一张 table 吗?它给了我其他表的错误,说同样的话“表没有用锁表锁定”

最佳答案

参见 http://dev.mysql.com/doc/refman/5.0/en/lock-tables.html :

If you use ALTER TABLE on a locked table, it may become unlocked. For example, if you attempt a second ALTER TABLE operation, the result may be an error Table 'tbl_name' was not locked with LOCK TABLES. To handle this, lock the table again prior to the second alteration. See also Section C.5.7.1, “Problems with ALTER TABLE”.

关于mysql - 使用锁定/解锁更改表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8792148/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com