6

When I was using type as bool when creating table it was directly converted into tinyint (1) , I don't know exact deference why mysql convert it into tinyint instead of datatype bool ?

  • For more information see: [Boolean vs tinyint(1) for boolean values in MySQL](http://stackoverflow.com/questions/3751853/boolean-vs-tinyint1-for-boolean-values-in-mysql) – Christian D. Apr 23 '15 at 09:31

2 Answers2

3

TINYINT Uses the smallest integer data type .

BOOL is equivalents of TINYINT(1).

Rex Rex
  • 1,030
  • 1
  • 8
  • 29
3

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

so whenever you try to create table with boolean datatype it automatically gets converted to inttype

e.g.
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

Seer
  • 5,226
  • 5
  • 33
  • 55
Amit Shah
  • 1,380
  • 1
  • 10
  • 19