- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How can I remove a value from an enum in MySQL?
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