Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

why mysql conver bool into tinyint(1) instead it should be bool into mysql table [duplicate]

Tags:

php

mysql

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 ?

like image 481
Pratik Panchal Avatar asked Apr 23 '15 09:04

Pratik Panchal


2 Answers

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

like image 177
Amit Shah Avatar answered Oct 03 '22 12:10

Amit Shah


TINYINT Uses the smallest integer data type .

BOOL is equivalents of TINYINT(1).

like image 30
Rex Rex Avatar answered Oct 03 '22 12:10

Rex Rex