我想知道是否有可能在整个表中更改ENUM
值,以便在表示所述ENUM
值的所有行中,也进行更改。
如果要更改enum的值:
假设你的旧enum是:
ENUM('English', 'Spanish', 'Frenchdghgshd', 'Chinese', 'German', 'Japanese')
修改:
-- Add a new enum value
ALTER TABLE `tablename` CHANGE `fieldname` `fieldname` ENUM
('English', 'Spanish', 'Frenchdghgshd', 'Chinese', 'German', 'Japanese', 'French');
-- Update the table to change all the values around.
UPDATE tablename SET fieldname = 'French' WHERE fieldname = 'Frenchdghgshd';
-- Remove the wrong enum from the definition
ALTER TABLE `tablename` CHANGE `fieldname` `fieldname` ENUM
('English', 'Spanish', 'Chinese', 'German', 'Japanese', 'French');
MySQL可能会遍历表中的所有行,尝试更新内容,我听说过有关计划优化的故事,但我不确定是否真的发生了。