반응형
SQL의 standard 타입 'boolean'
boolean 타입은 "true" 또는 "false"의 값을 갖는다.
기본적으로 true, false를 갖지만 아래와 같이 표현할 수 있다.
- true : true, y, on, 1
- false : false, n, off, 0
'yes'::boolean -> true
'no'::boolean -> false
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
CREATE TABLE booltest (flag boolean);
INSERT INTO booltest VALUES (TRUE), ('no'), ('0'), ('yes'), (FALSE);
SELECT * FROM booltest;
flag
------
t
f
f
t
f
REFERENCES
PostgreSQL : Documentation: 13: PostgreSQL 13.7 Documentation
postgrespro.com
반응형
'DB > PostgreSQL' 카테고리의 다른 글
[PostgreSQL] PostgreSQL의 통화 타입에 대해서 알아보자. (Monetary Types) (0) | 2022.06.17 |
---|---|
[PostgreSQL] PostgreSQL의 Enum 타입에 대해서 알아보자. (0) | 2022.06.17 |
[PostgreSQL] PostgreSQL의 이진 타입에 대해서 알아보자. (Binary Type) (0) | 2022.06.14 |
[PostgreSQL] PostgreSQL의 문자 타입에 대해서 알아보자. (Character Types) (0) | 2022.06.14 |
[PostgreSQL] PostgreSQL의 숫자 타입에 대해서 알아보자. (0) | 2022.06.06 |