How can I remove a value from an enum in mysql? How can I remove a value from an enum in mysql? database database

How can I remove a value from an enum in mysql?


Try this :-

alter table tablenamechange `columname`  `columname` enum ('one', 'three');

Its working fine.


Enums are saved as integers so all your rows with enum="one" is actually equal to 1, enum="two" is 2 and enum="tree" is 3.

Seems MySQL is doing all the magic to change those values if enum names match so you just need to make sure there are no rows with 'two'

http://sqlfiddle.com/#!2/ef76d/1

CREATE TABLE `tablename` (`name` VARCHAR(32), `enumname` ENUM('one', 'two', 'three'));INSERT INTO `tablename` VALUES ('one', 'one'),('two', 'two'),('three', 'three');DELETE FROM `tablename` WHERE `enumname`=2;ALTER TABLE `tablename` MODIFY `enumname` ENUM('one', 'three');


Yes you can do that. Here is an example :

ALTER TABLE `database`.`tablename`CHANGE `enumname` `enumname` ENUM('one','two')CHARSET utf8 COLLATE utf8_general_ci NULL;