Tutorialspoint

1 Answer
Smita Kapse

Use ALTER command to remove a value from an enum in MySQL. Let us first create a table −

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;

This will produce the following output −

+-------+-----------------------------+------+-----+---------+-------+
| Field | Type                        | Null | Key | Default | Extra |
+-------+-----------------------------+------+-----+---------+-------+
| Rank  | enum('LOW','MEDIUM','HIGH') | YES  |     | NULL    |       |
+-------+-----------------------------+------+-----+---------+-------+
1 row in set (0.00 sec)

Following is the query to remove a value from an enum in 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

Now let us check the description of table once again −

mysql> DESC DemoTable;

This will produce the following output −

+-------+--------------------+------+-----+---------+-------+
| Field | Type               | Null | Key | Default | Extra |
+-------+--------------------+------+-----+---------+-------+
| Rank | enum('LOW','HIGH') | YES | | NULL | |
+-------+--------------------+------+-----+---------+-------+
1 row in set (0.00 sec)

Advertisements

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.