- publishing free software manuals
The PostgreSQL 9.0 Reference Manual - Volume 1A - SQL Language Reference
by The PostgreSQL Global Development Group
Paperback (6"x9"), 454 pages
ISBN 9781906966041
RRP £14.95 ($19.95)

Sales of this book support the PostgreSQL project! Get a printed copy>>>

6.6 Boolean Type

PostgreSQL provides the standard SQL type boolean; see Table 6-19. The boolean type can have one of only two states: “true” or “false”. A third state, “unknown”, is represented by the SQL null value.

Table 6-19: Boolean Data Type
Name Storage Size Description
boolean 1 byte state of true or false

Valid literal values for the “true” state are:

For the “false” state, the following values can be used:

Leading or trailing whitespace is ignored, and case does not matter. The key words TRUE and FALSE are the preferred (SQL-compliant) usage.

section 6.6 Boolean Type shows that boolean values are output using the letters t and f.

Using the boolean type:

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
---+---------
 t | sic est
 f | non est

SELECT * FROM test1 WHERE a;
 a |    b
---+---------
 t | sic est
ISBN 9781906966041The PostgreSQL 9.0 Reference Manual - Volume 1A - SQL Language ReferenceSee the print edition