PostgreSQL 8.0.1 Documentation | ||||
---|---|---|---|---|
Prev | Fast Backward | Chapter 8. Data Types | Fast Forward | Next |
8.6. Boolean Type
PostgreSQL provides the standard SQL type boolean. boolean can have one of only two states: "true" or "false". A third state, "unknown", is represented by the SQL null value.
Valid literal values for the "true" state are:
TRUE |
't' |
'true' |
'y' |
'yes' |
'1' |
FALSE |
'f' |
'false' |
'n' |
'no' |
'0' |
Example 8-2. Using the boolean type
Example 8-2 shows that boolean values are output using the letters t and f.
Tip: Values of the boolean type cannot be cast directly to other types (e.g., CAST (boolval AS integer) does not work). This can be accomplished using the CASE expression: CASE WHEN boolval THEN 'value if true' ELSE 'value if false' END. See Section 9.13.
boolean uses 1 byte of storage.