This page in other versions: 8.4 / 9.0 / 9.1 / 9.2 / 9.3  |  Development versions: devel  |  Unsupported versions: 7.1 / 7.2 / 7.3 / 7.4 / 8.0 / 8.1 / 8.2 / 8.3

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:

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.

Example 8-2. 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

 a |    b
 t | sic est

Example 8-2 shows that boolean values are output using the letters t and f.

boolean uses 1 byte of storage.


Jan. 13, 2010, 7:25 a.m.

SQL Server and MySQL are using BIT for BOOLEAN.
The literals for BIT are 0 and 1 as integers.
Unfortunately this isn't supported here and all related code has to be rewritten upon migration.

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group