Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

From MySQL manual, it says:

BOOL, BOOLEAN

These types are synonyms for TINYINT(1). A value of zero is considered false. Nonzero values are considered true:

I created a BOOLEAN column with 0 as the default value. Then I update the value to 2. Logically, I would expect MySQL to accept either 0 or 1 since it is a boolean. However, MySQL did not issue an error or prevent me from performing the update.

If BOOLEAN works exactly the same as TINYINT(1), does it make any difference whether I use TINYINT(1) or BOOLEAN?

share|improve this question
1  
Those two are really synonyms, so you can use them interchangeably, AFAIK. You won't see any difference between them. (Personally, as I use PostgreSQL 99.9% of the time, I feel this being one of the most annoying 'features' of MySQL.) –  dezso Nov 9 '12 at 10:57
    
@dezso sounds like a good answer to me (except perhaps the personal viewpoint). should post it :) –  Derek Downey Nov 9 '12 at 14:30

1 Answer 1

up vote 3 down vote accepted

Those two are really synonyms, so you can use them interchangeably. You won't see any difference between them.

If you want to allow 0 and 1 only, you can still use the bit type.

share|improve this answer
    
lol, seems like they are inventing something for nothing then.. BIT is a bit complicated to use, maybe I will just stick to TINYINT then.. –  Question Overflow Nov 10 '12 at 8:37
    
@QuestionOverflow Keep in mind that BIT is really a bit field that holds one to sixty-four bits compactly. –  David Harkness Sep 23 at 22:07

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.