Lets say in some random table, you have a column named status. It's real-world values would be either enabled or disabled.
Is it better for this column's data type to be an int/bool (1 or zero) or to use
ENUM
with the values beingenabled
and disabled
? What are the advantages or disadvantages?
Let's say instead of just two valid status's, you have 4 or 10 or even more? Do the advantages and disadvantages sway to one side or the other as the number of required values increases?
Answer:
You can see a lot of links on the internet show that we should not use ENUM type like:
and more from stackExchange:
- there is no easy method for adding new values, some techniques are very high risk
- numbers should never be used
- only use strings (@DTest already mentioned this in his answer)
- ENUM takes 1 byte (if under 255 values) or 2 bytes (up to maximum of 65,535
- TinyInt takes 1 byte (maximum of 255 values)
- Boolean is a synonym for TinyInt
- No capability for additional metadata about the code.
- I18n in the database can not be done.
- Not reusable across tables.