principlesqlMajor
Bit vs. Boolean columns
Viewed 0 times
bitcolumnsboolean
Problem
Given that bit fields are just binary representations of data and need to be queried in slightly "strange" way.
Does it actually provide any benefit using a bit field for a boolean value? From what I can see it seems to suggest that space is the only real benefit.
Does it actually provide any benefit using a bit field for a boolean value? From what I can see it seems to suggest that space is the only real benefit.
Solution
Personally, I would use the
This, of course, means you can have values other than 0 or 1 if you are not careful. To avoid this, you can use the aliases
For the sake of being complete, prior to 5.0.3,
BOOLEAN for a boolean value. But keep in mind the caveat that in MySQL, BOOLEAN is just a synonym of TINYINT(1) [src]. This, of course, means you can have values other than 0 or 1 if you are not careful. To avoid this, you can use the aliases
TRUE and FALSE when inserting and updating data, as those map to 1 and 0 respectively.For the sake of being complete, prior to 5.0.3,
BIT was also a synonym of TINYINT(1).Context
StackExchange Database Administrators Q#15801, answer score: 20
Revisions (0)
No revisions yet.