Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does MySQL's boolean type map to a tinyint instead of an enum?

Tags:

mysql

Were there performance or compatibility reasons for going with tinyint(1) over an enum? Something else?

like image 774
Nevir Avatar asked Dec 18 '25 04:12

Nevir


1 Answers

It may interest you to know that MySQL indexes ENUMs with integers.

The SQL standard has included a boolean data type since 1999 - with valid values being true, false, unknown, or null. Implementation across various database systems is spotty.

MySQL does not support a true boolean data type - BOOLEAN maps to TINYINT, which takes up only 1 byte. MySQL interprets 0 as false, all other numbers are true.

like image 112
TehShrike Avatar answered Dec 19 '25 21:12

TehShrike



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!