如何从 MySQL 中的枚举中删除值?
mysqlmysqli database更新于 2025/9/18 21:32:17
使用 ALTER 命令从 MySQL 中的枚举中删除值。让我们首先创建一个表 −
mysql> create table DemoTable ( `Rank` ENUM('LOW','MEDIUM','HIGH') ); Query OK, 0 rows affected (0.52 sec)
Let us check the description of table.
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)
相关文章
有用资源
mysql 参考教程 - 该教程包含有关 mysql 的更多信息:https://www.cainiaomax.com/mysql/

