I use tinyint (1) for fields which contain either 1 or 0, for xample, is_active. I can use enum (‘1′,’0’) instead but not sure which cases I should use enum or tinyint. Any comments/suggetion?
Thanks
Js
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
In your case both
enumandtinyintwill have the same size (i.e.1 byte). However, theenumoption is less flexible if your data changes. So use it if you’re absolutely sure your data definition will not change (eg. what if you will you be adding a'disabled'state in the future?).If you decide to stick with the
enuma definition likeenum('active', 'not_active')is more practical.