| PostgreSQL Reference Manual - Volume 1 - SQL Language Reference by The PostgreSQL Global Development Group Paperback (6"x9"), 716 pages ISBN 0954612027 RRP £32.00 ($49.95) Sales of this book support the PostgreSQL project! Get a printed copy>>> |
6.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'
For the “false” state, the following values can be used:
-
FALSE -
'f' -
'false' -
'n' -
'no' -
'0'
Using the key words TRUE and
FALSE is preferred (and
SQL-compliant).
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
section 6.6 Boolean Type shows that
boolean values are output using the letters
t and f.
boolean uses 1 byte of storage.
| ISBN 0954612027 | PostgreSQL Reference Manual - Volume 1 - SQL Language Reference | See the print edition |