# 8.6. Boolean Type
PostgreSQL provides the standard SQL type
boolean; see Table 8.19. The
boolean type can have several states: “true”, “false”, and a third state, “unknown”, which is represented by the SQL null value.
Table 8.19. Boolean Data Type
| ||1 byte||state of true or false|
Boolean constants can be represented in SQL queries by the SQL key words
The datatype input function for type
boolean accepts these string representations for the “true” state:
and these representations for the “false” state:
Unique prefixes of these strings are also accepted, for example
n. Leading or trailing whitespace is ignored, and case does not matter.
The datatype output function for type
boolean always emits either
f, as shown in Example 8.2.
Example 8.2. Using the
CREATE TABLE test1 (a boolean, b text); INSERT INTO test1 VALUES (TRUE, 'sic est'); INSERT INTO test1 VALUES (FALSE, 'non est'); SELECT * FROM test1; a | b