Movatterモバイル変換


[0]ホーム

URL:



Facebook
Postgres Pro
Facebook
Downloads

8.6. Boolean Type

PostgreSQL provides the standardSQL typeboolean; seeTable 8-19. Theboolean type can have several states:"true","false", and a third state,"unknown", which is represented by theSQL null value.

Table 8-19. Boolean Data Type

NameStorage SizeDescription
boolean1 bytestate of true or false

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 wordsTRUE andFALSE are the preferred (SQL-compliant) usage.

Example 8-2 shows thatboolean values are output using the letterst andf.

Example 8-2. Using theboolean 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 estSELECT * FROM test1 WHERE a; a |    b---+--------- t | sic est

PrevHomeNext
Date/Time TypesUpEnumerated Types
Go to PostgreSQL 9.4
By continuing to browse this website, you agree to the use of cookies. Go toPrivacy Policy.

[8]ページ先頭

©2009-2025 Movatter.jp