MySQL TINYINT (1) vs. BIT (1)

Please enlighten me ...

Which datatype is consuming the smallest, TINYINT (1) or BIT (1)?

I know that TINYINT (1) and BIT (1) are considered the same according to most of the answers here.

Doesn't TINYINT (1) do 0-9, whereas BIT (1) can only 1 or 0. In appearance, TINYINT uses more storage because it can accept 2-9, whereas BIT only can 1 and 0.

+3


source to share


1 answer


TINYINT will always be one (1) byte in size. And take values ​​between -128 and 127 (if signed).

The number in parentheses is for display.



BIT (1), on the other hand, only takes up one bit in storage, but must be aligned with respect to whole bytes, which means if you only have one BIT (1) column, one byte is used, but if you have there are several they can be placed in the same byte.

+2


source







All Articles