使用ALTER命令从MySQL的枚举中删除一个值。让我们首先创建一个表-
mysql> create table DemoTable ( `Rank` ENUM('LOW','MEDIUM','HIGH') ); Query OK, 0 rows affected (0.52 sec)
让我们检查表的描述。
mysql> DESC DemoTable;
这将产生以下输出-
+-------+-----------------------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------+-----------------------------+------+-----+---------+-------+ | Rank | enum('LOW','MEDIUM','HIGH') | YES | | NULL | | +-------+-----------------------------+------+-----+---------+-------+ 1 row in set (0.00 sec)
以下是从MySQL枚举中删除值的查询。
mysql> alter table DemoTable change `Rank` `Rank` ENUM('LOW','HIGH'); Query OK, 0 rows affected (1.19 sec) Records: 0 Duplicates: 0 Warnings: 0
现在让我们再次检查表的描述-
mysql> DESC DemoTable;
这将产生以下输出-
+-------+--------------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------+--------------------+------+-----+---------+-------+ | Rank | enum('LOW','HIGH') | YES | | NULL | | +-------+--------------------+------+-----+---------+-------+ 1 row in set (0.00 sec)