Why mysql convert bool to tinyint (1), instead it should be bool in mysql table

When I used the type as bool when creating the table, it was directly converted to tinyint (1), I don’t know the exact respect why mysql converts it to tinyint instead of datatype bool?

+6
source share
2 answers

BOOL is the equivalent of TINYINT (1). TINYINT Uses the smallest integer data type.

so whenever you try to create a table with a boolean data type, it is automatically converted to inttype

eg CREATE TABLE IF NOT EXISTS `test` ( `p_id` int(11) NOT NULL, `p_name` varchar(25) NOT NULL, `p_description` varchar(100) NOT NULL, `p_status` bool NOT NULL DEFAULT TRUE ) 

Thanks Amit

+3
source

TINYINT Uses the smallest integer data type.

BOOL is the equivalent of TINYINT (1).

+3
source

Source: https://habr.com/ru/post/985764/


All Articles