deltanovember
deltanovember

Reputation: 44051

How does MySQL handle storing ENUM value that doesn't exist?

For example suppose my ENUM is "a", "b", "c" and I try to store "d" how is MySQL supposed to behave? Also from a design perspective is there a correct way of handling this case? (your program receives "d" fo the above enum)

Upvotes: 1

Views: 190

Answers (1)

Ewan Heming
Ewan Heming

Reputation: 4648

If you are using strict mode then an error will occur otherwise it will store an empty string with a value of zero.

The correct way to handle this case would be to ensure invalid values never get inserted or use another data type.

Upvotes: 3

Related Questions