Recall & Review
beginner
What values can a PostgreSQL Boolean type store?
A PostgreSQL Boolean type can store three values: true, false, and NULL (unknown).
Click to reveal answer
beginner
How does PostgreSQL interpret the string 't' when cast to Boolean?
PostgreSQL interprets the string 't' as true when cast to Boolean.
Click to reveal answer
intermediate
What happens when you use a Boolean column in a WHERE clause in PostgreSQL?
The WHERE clause treats true as passing the condition, false as failing, and NULL as unknown, so rows with NULL in that column are excluded unless explicitly handled.
Click to reveal answer
intermediate
Can you use Boolean values in arithmetic operations in PostgreSQL?
No, Boolean values cannot be directly used in arithmetic operations. You must cast them to integers (true = 1, false = 0) first.
Click to reveal answer
beginner
How do you explicitly cast a Boolean to text in PostgreSQL?
Use the CAST operator or :: syntax, for example:
SELECT true::text; returns 't'.Click to reveal answer
Which of these is NOT a valid Boolean literal in PostgreSQL?
✗ Incorrect
PostgreSQL accepts 'true', 'false', 't', 'f' as Boolean literals, but 'xyz' is not recognized as a Boolean.
What does the expression
SELECT NULL::boolean; return?✗ Incorrect
Casting NULL to boolean results in NULL, representing an unknown Boolean value.
In a WHERE clause, what happens to rows where the Boolean column is NULL?
✗ Incorrect
Rows with NULL in a Boolean column are excluded because NULL means unknown, which does not satisfy the WHERE condition.
How can you convert a Boolean true to integer 1 in PostgreSQL?
✗ Incorrect
You must explicitly cast Boolean to integer using CAST or :: syntax; arithmetic operations on Boolean are not allowed.
Which of these is the correct way to cast Boolean false to text?
✗ Incorrect
Casting Boolean false to text uses false::text or CAST(false AS text).
Explain how PostgreSQL handles Boolean values and their behavior in queries.
Think about how true, false, and NULL affect filtering and casting.
You got /4 concepts.
Describe how to convert Boolean values to other types in PostgreSQL and why it might be necessary.
Consider when you want to display or calculate with Boolean values.
You got /4 concepts.