Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MySql doesn't accept boolean as its column datatype

I have a Java program which stores data in MySQL database in two states. For this purpose I wanted to use BOOLEAN. But whenever I enter BOOLEAN it's getting changed into TINYINT.

Is there any other way to store data in two states?

like image 552
pritam parab Avatar asked Feb 23 '26 04:02

pritam parab


1 Answers

MySQL uses TINYINT(1) to mimic the behaviour of Boolean type, so make sure you use TINYINT(1) as the data type of your column, not TINYINT.

Alternatively, you can use BOOL or BOOLEAN which are both synonyms for TINYINT(1).

Similarly, the values TRUE and FALSE are merely aliases for 1 and 0, respectively in MySQL.

like image 149
Racil Hilan Avatar answered Feb 25 '26 20:02

Racil Hilan



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!