
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Difference Between TINYINT(1) and BOOLEAN in MySQL
There is no difference between TINYINT(1) and Boolean. The keyword Bool or Boolean internally converts into TINYINT(1) or we can say Bool or Boolean are synonymous with TINYINT(1).
Let us first create a table −
mysql> create table DemoTable ( isMarried Boolean ); Query OK, 0 rows affected (1.77 sec)
Let us check the description of the table −
mysql> desc DemoTable;
This will produce the following output −
+-----------+------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-----------+------------+------+-----+---------+-------+ | isMarried | tinyint(1) | YES | | NULL | | +-----------+------------+------+-----+---------+-------+ 1 row in set (0.01 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable values(true); Query OK, 1 row affected (0.30 sec) mysql> insert into DemoTable values(false); Query OK, 1 row affected (0.16 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
This will produce the following output −
+-----------+ | isMarried | +-----------+ | 1 | | 0 | +-----------+ 2 rows in set (0.00 sec)
Advertisements