BOOLEAN
A logical TRUE or FALSE value.
Aliases: BOOL
Example
SELECT TRUE;Casting
| From | Example | Notes |
|---|---|---|
| from INTEGER | 1::BOOLEAN |
0 → FALSE, any non-zero → TRUE |
| from FLOAT | 1.0::BOOLEAN |
0.0 → FALSE, any non-zero → TRUE |
| from VARCHAR | 'true'::BOOLEAN |
Exact matches only (case-insensitive): true/false, 1/0, yes/no, on/off. Any other value raises an error — including empty string, 'null', and 'none'. |
Comparisons
Can be compared (using =, <, >, etc.) with: BOOLEAN.
Limitations
- BOOLEAN cannot be compared to numeric types directly. Cast first:
col::INTEGER = 1. - Plain
CAST(... AS BOOLEAN)/::BOOLEANraises on an unrecognised string — there is no silent fallback. HoweverTRY_CAST(... AS BOOLEAN)and element parsing insideCAST(... AS ARRAY<BOOLEAN>)do NOT raise and do NOT return NULL for garbage input — they silently coerce any unrecognised string to FALSE.