TUTORIAL INDEX

MySQL Boolean Data Type

|

What is Boolean Data Type in MySQL?

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:

Suppose you want to create a table to store whether an employee is active or not. In this case, you use the BOOLEAN data type to store TRUE or FALSE values.


Query:

CREATE TABLE emp_tbl (
    is_active BOOLEAN
);

Output:

is_active
---------
1
0

Explanation:

The is_active column 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:

  • 1 is used to represent TRUE
  • 0 is used to represent FALSE

ONLINE WEB TOOLS

WhatIsMyIpAddress
Shorterner