The Boolean data type refers to storing true/false values.
When you create a table in MySQL, you define the Boolean data type so that only TRUE or FALSE values can be inserted into that column.
Syntax:
CREATE TABLE table_name (
column_name BOOLEAN
);
Example:
Query:
CREATE TABLE emp_tbl (
is_active BOOLEAN
);
Output:
is_active --------- 1 0
Explanation:
- The
is_activecolumn stores TRUE or FALSE values because it is defined with the Boolean data type.
Note:
In MySQL, the Boolean Data Type is essentially represented as TINYINT(1), where:
1is used to represent TRUE0is used to represent FALSE
