Introduction
Boolean type helps store true or false values simply and clearly in a database.
column_name BOOLEANCREATE TABLE users ( id SERIAL PRIMARY KEY, is_active BOOLEAN );
INSERT INTO users (is_active) VALUES (TRUE), (FALSE), (NULL);
SELECT * FROM users WHERE is_active = TRUE;
CREATE TEMP TABLE tasks ( id SERIAL PRIMARY KEY, description TEXT, is_done BOOLEAN ); INSERT INTO tasks (description, is_done) VALUES ('Wash dishes', FALSE), ('Do homework', TRUE), ('Read book', NULL); SELECT id, description, is_done FROM tasks ORDER BY id;
is_active in a PostgreSQL table?settings with a boolean column enabled, what will this query return?SELECT enabled FROM settings WHERE enabled = FALSE;
SELECT * FROM users WHERE is_admin = TRUE;
is_admin column is boolean but some rows have NULL. What is the likely issue?tasks where the boolean column completed is either FALSE or NULL. Which query correctly does this?Pass the test and this pattern moves unknown