如果要更改枚举的值:

假设你的旧枚举是:

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可能会通过表中的所有行尝试更新内容,我听说过有关计划优化的故事,但我不知道是否真的发生了这样的事情.

Logo

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。

更多推荐