MySQL Data Types: int versus enum

I have several columns that need to store only a few values ​​(e.g. 0, 1, 2, 3). What type of data should be chosen for this case? It seems to me that I should choose something like ENUM ('0', '1', '2'). Would it be better (although it would be less restrictive)? Should I consider something else (e.g. tinyint)?

EDIT:

Actually, what general advice should be considered when choosing a data type?

+4
source share
2 answers

If you want to limit this to these 3 values, then really ENUM may be the best.

If, however, it is likely that more values ​​may be required in the future, then TINYINT UNSIGNED is probably the best solution.

+5
source

It is recommended that you use a fixed-set enumeration. If you want to extend, then this β€œChange” is basically a change to the scheme that should be avoided.

Find a better understanding of data type selection

and get an enumeration comparison with data types

+1
source

All Articles