Home >Database >Mysql Tutorial >What is the difference between MySQL's BOOL and BOOLEAN column data types?
Both BOOL and BOOLEAN work like TINYINT(1). You can say that they are all synonyms for TINYINT(1).
This is an example of BOOLEAN. A query that creates a table with columns of type boolean.
mysql> create table Demo -> ( -> isVaidUser boolean -> ); Query OK, 0 rows affected (1.08 sec)
The query to insert records into the table using the insert command is as follows −
mysql> insert into Demo values(true); Query OK, 1 row affected (0.19 sec) mysql> insert into Demo values(0); Query OK, 1 row affected (0.17 sec)
Use the select command to display all values in the table. The query is as follows −
mysql> select *from Demo;
+------------+ | isVaidUser | +------------+ | 1 | | 0 | +------------+ 2 rows in set (0.00 sec)
This is an example of BOOL. The following is the query to create the table −
mysql> create table Demo1 -> ( -> isVaidUser bool -> ); Query OK, 0 rows affected (0.54 sec)
Use the insert command to insert records in the table. The query is as follows −
mysql> insert into Demo1 values(1); Query OK, 1 row affected (0.14 sec) mysql> insert into Demo1 values(false); Query OK, 1 row affected (0.16 sec)
Use the select command to display all values in the table. The query is as follows −
mysql> select *from Demo1;
+------------+ | isVaidUser | +------------+ | 1 | | 0 | +------------+ 2 rows in set (0.00 sec)
Look at the sample output, false is converted to 0. That means BOOL and BOOLEAN implicitly convert into tinyint(1).
The above is the detailed content of What is the difference between MySQL's BOOL and BOOLEAN column data types?. For more information, please follow other related articles on the PHP Chinese website!