LazNiko
LazNiko

Reputation: 2113

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

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?

Upvotes: 9

Views: 1896

Answers (1)

gbn
gbn

Reputation: 432261

It depends on version and database engine and driver

  • BIT is supported properly in 5.05+ with MyISAM and InnoDB
  • Some JDBC drivers need to be told this (eg Kettle's bundled driver)

But BIT is preferable to TINYINT of course.
It's just legacy and inertia that keeps TINYINT...

Upvotes: 6

Related Questions