Jeetendra Pujari
Jeetendra Pujari

Reputation: 1344

Mysql Add a new value to a column of data type enum

Say I have a mysql table, and I have a column of type enum and that column has defined set of values like enum('a','b','c','d').

How would i add a value of 'e' to this set using alter table statement?

And I want to append the new value to the end of it using CONCAT.

Upvotes: 32

Views: 37684

Answers (2)

Muhammad Shahzad
Muhammad Shahzad

Reputation: 9652

If you want to add default value and also want after a specific column for enum, try this query:

Alter table `your_table` 
Add column `visible_on` enum('web','mobile','both') default 'both' 
After `your_column`;

Upvotes: -3

Asaph
Asaph

Reputation: 162791

Unfortunately, you need to re-list all the existing enum values when adding a new value to the the enum.

ALTER TABLE mytable MODIFY COLUMN mycolumn ENUM('a','b','c','d','e');

You don't really want to use CONCAT() in this situation.

Upvotes: 50

Related Questions