principlesqlCritical
Advantages and Disadvantages to using ENUM vs Integer types?
Viewed 0 times
advantagesenumusingdisadvantagestypesandinteger
Problem
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
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?
Is it better for this column's data type to be an int/bool (1 or zero) or to use
ENUM with the values being enabled 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?
Solution
I found a very bizarre but informative article about 8 reasons why one should not use ENUM.
Even without the article, I know
Even without the article, I know
- 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)
Context
StackExchange Database Administrators Q#6962, answer score: 94
Revisions (0)
No revisions yet.