Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between boolean and bool in MySQL? [duplicate]

Tags:

mysql

I am learning MySQL and when I wanted to add a boolean column, I saw there were two options: bool and boolean. Is there any difference between them? Thank you for your time.

Edit: what should I write in the length of the bool type.

like image 529
Alex Terreaux Avatar asked Oct 08 '12 21:10

Alex Terreaux


People also ask

What is the difference between Bool and boolean in MySQL?

MySQL does not have a boolean (or bool) data type. Instead, it converts boolean values into integer data types (TINYINT). When you create a table with a boolean data type, MySQL outputs data as 0, if false, and 1, if true.

What is boolean in MySQL?

A Boolean is the simplest data type that always returns two possible values, either true or false. It can always use to get a confirmation in the form of YES or No value. MySQL does not contain built-in Boolean or Bool data type.

How do you set a boolean to true in MySQL?

You can update boolean value using UPDATE command. If you use the BOOLEAN data type, MySQL internally convert it into tinyint(1). It can takes true or false literal in which true indicates 1 to tinyint(1) and false indicates 0 to tinyint(1).

Why is boolean Tinyint in MySQL?

In MySQL, TINYINT(1) and boolean are synonymous. Because of this, the MySQL driver implicitly converts the TINYINT(1) fields to boolean if the the Java tinyInt1isBit configuration property is set to true (which is the default) and the storage size is 1. Stitch then interprets these columns as BIT(1)/boolean .


1 Answers

BOOL and BOOLEAN are both synonyms from TINYINT(1) (source). In other words, there is no difference.

like image 81
CrazyCasta Avatar answered Sep 27 '22 15:09

CrazyCasta