32

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.

2 Answers 2

50

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.

Sign up to request clarification or add additional context in comments.

1 Comment

how to set default value in this statement. SET DEFAULT 'a' doesn't work for me.
-3

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`;

2 Comments

How is this related to the question?
Thank you for this code snippet, which might provide some limited short-term help. A proper explanation would greatly improve its long-term value by showing why this is a good solution to the problem, and would make it more useful to future readers with other, similar questions. Please edit your answer to add some explanation, including the assumptions you've made.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.