Recall & Review
beginner
What is a Boolean column in a database?
A Boolean column stores values that can only be true or false. It helps to represent yes/no or on/off states in data.
Click to reveal answer
beginner
How do you filter rows where a Boolean column is true in PostgreSQL?
Use
WHERE column_name = TRUE or simply WHERE column_name to get rows where the Boolean column is true.Click to reveal answer
beginner
How do you filter rows where a Boolean column is false in PostgreSQL?
Use
WHERE column_name = FALSE or WHERE NOT column_name to get rows where the Boolean column is false.Click to reveal answer
intermediate
What happens if you filter a Boolean column with
WHERE column_name IS NULL?It returns rows where the Boolean column has no value (NULL). This is different from true or false and means the value is unknown or missing.
Click to reveal answer
intermediate
Why might you use
WHERE column_name IS NOT TRUE instead of WHERE column_name = FALSE?Because
IS NOT TRUE includes both false and NULL values, while = FALSE only includes false. This helps catch unknown or missing data too.Click to reveal answer
Which SQL clause filters rows where a Boolean column named 'active' is true?
✗ Incorrect
To filter rows where 'active' is true, use WHERE active = TRUE or simply WHERE active.
How do you select rows where a Boolean column 'subscribed' is false?
✗ Incorrect
WHERE NOT subscribed filters rows where 'subscribed' is false.
What does
WHERE flag IS NULL return?✗ Incorrect
IS NULL returns rows where the Boolean column has no value (NULL).
Which clause includes rows where a Boolean column is false or NULL?
✗ Incorrect
IS NOT TRUE includes both false and NULL values.
What is the simplest way to filter rows where a Boolean column 'enabled' is true?
✗ Incorrect
WHERE enabled is a shorthand for WHERE enabled = TRUE.
Explain how to filter rows based on a Boolean column in PostgreSQL for true, false, and NULL values.
Think about how true, false, and unknown values are stored and checked.
You got /3 concepts.
Describe why you might use 'IS NOT TRUE' instead of '= FALSE' when filtering Boolean columns.
Consider how NULL values behave in Boolean filtering.
You got /3 concepts.