I would like to add a column to the table which contains either of two values: 1 or 0.
What would be the smallest datatype to store the data in MySQL?
A TINYINT(1) can contain numbers between -127 to 127.
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.
You can use bit(1)
http://dev.mysql.com/doc/refman/5.0/en/storage-requirements.html
BOOL is stored in MySQL as TINYINT which would take 1 full byte
http://dev.mysql.com/doc/refman/5.0/en/other-vendor-data-types.html
A bit(1) would normally also take 1-byte but if there are multiple bits in a single record, then they get stored in the same byte, up to 8 per byte.