BOOLEAN
BOOLEAN in SQL is a data type. It is used to store true/false values. The values it can store are TRUE, FALSE, or NULL.
Example
Output
Explanation
In the example provided, a table employees
is created with a column is_manager
of BOOLEAN
type. Two rows are then inserted into the table, with ‘John Doe’ having a is_manager
value of TRUE
and ‘Jane Doe’ having an is_manager
value of FALSE
. The SELECT statement retrieves all employees for which the is_manager
field is TRUE
, thus the output includes the record for ‘John Doe’ only.
Example
Output
Explanation
In this case, SQLite does not have built-in BOOLEAN type. However, it uses INTEGER to store Boolean values. SQLite uses 0 for FALSE and 1 for TRUE. The table Employee
created includes a column is_manager
of type BOOLEAN. By inserting the values into Employee
, when fetching the data from the table, it shows 1 for TRUE input and 0 for FALSE input.