Why does MySQL interpret Boolean as TINYINT (1) instead of BIT (1)?

When considering only two possible values: 0 and 1 or True and False, it is quite obvious that BIT (1) does a better job:

  • BIT (1) sets only 2 possible values: 0 and 1, while TINYINT (1) can take any integer values ​​less than 10 (0,1,2,3,4,5 ....), which can be ambiguous.
  • Multiple BIT (1) columns can be combined into bytes so that they require less space than multiple TINYINT (1) columns.

So why does MySQL interpret Boolean as TINYINT (1) but not BIT (1)? Is there any advantage to using TINYINT (1) over BIT (1) when processing boolean values?

+7
source share
1 answer

It depends on the version and mechanism of the database and driver.

  • BIT is supported in 5.05+ with MyISAM and InnoDB
  • Some JDBC drivers should be mentioned (for example, bundled with the Kettle driver).

But BIT is preferable to TINYINT, of course.
It is just the legacy and inertia that holds TINYINT ...

+5
source

All Articles