| 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.
Valid literal values for the “true” state are:
-
TRUE -
't' -
'true' -
'y' -
'yes' -
'on' -
'1'
For the “false” state, the following values can be used:
-
FALSE -
'f' -
'false' -
'n' -
'no' -
'off' -
'0'
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 9781906966041 | The PostgreSQL 9.0 Reference Manual - Volume 1A - SQL Language Reference | See the print edition |