I am trying to add a
BOOLEAN column using EDIT TABLE in mysql workbench, but it automatically changes to
TINYINT on applying changes.
How can I get the column to be
You probably want to use the
MySQL doesn't support true booleans as per standard SQL. It uses integer values 1 and 0 respectively for true and false. It does support the keywords
They really are mapped to integers:
This does mean that certain expressions are simpler in MySQL, such as counting the rows where a certain value is true is as easy as SUM() of a boolean expression, which will be 1 where the condition is true and 0 otherwise.
Standard SQL doesn't support this use of booleans as integers, and would require the more verbose:
As other answers have already noted, you can use a data type alias
In Mysql you can't have bool, because in Mysql bool is Tinyint, just that it's converted when you create the table.So you can "create" the bool and you can use it as a boolean, but it's a tinyint.
the bool_field I created as bool and mysql put it as tinyint(1).
if you want to set it as true or false, in the programming world 1 is true and 0 is false.
You can even make conditionals with 1 and 0, like