开发者

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

开发者 https://www.devze.com 2023-02-13 05:59 出处:网络
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 ha开发者_C百科ndling this case? (yo

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 ha开发者_C百科ndling this case? (your program receives "d" fo the above enum)


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消