When considering only two possible values, 0 & 1 or True & False, it is quite obvious that BIT(1) does a better job:
So why MySQL interprets Boolean as TINYINT(1), but not BIT(1)? Is there any advantage of using TINYINT(1) over BIT(1) in handling boolean values?
The basic difference between Boolean and tinyint(1) is only in the naming convention. If we say that we need true or false values then Boolean comes to our mind, instead of tinyint(1). These data types are synonyms. It is up to us which data type we want to use- values can be 1 and 0 or true and false.
Yes, MySQL internally convert bool to tinyint(1) because tinyint is the smallest integer data type.
There is no difference between TINYINT(1) and Boolean. The keyword Bool or Boolean internally converts into TINYINT(1) or we can say Bool or Boolean are synonymous with TINYINT(1).
The number 1 used in parenthesis is only for width display. The INT(1) and TINYINT(1) does not influence the storage. The TINYINT takes 1 byte that means it has range -128 to +127 while int takes 4 bytes; it has range -2147483648 to +2147483647.
It depends on version and database engine and driver
But BIT is preferable to TINYINT of course.
It's just legacy and inertia that keeps TINYINT...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With