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?
Best Answer
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.