PostgreSQL has a rich set of native data types available to users. Users may add new types to PostgreSQL using the CREATE TYPE command.
표 8-1 shows all the built-in general-purpose data types. Most of the alternative names listed in the "Aliases" column are the names used internally by PostgreSQL for historical reasons. In addition, some internally used or deprecated types are available, but they are not listed here.
표 8-1. 자료형
| 이름 | 별칭 | 설명 |
|---|---|---|
| bigint | int8 | 부호있는 8바이트 정수 |
| bigserial | serial8 | 자동증가 8바이트 정수 |
| bit [ (n) ] | 고정길이 비트 문자열 | |
| bit varying [ (n) ] | varbit | 가변길이 비트 문자열 |
| boolean | bool | 논리적 불린형 (true/false) |
| box | 평면에서 표현되는 사각형 | |
| bytea | 이진 자료 ("바이트 배열") | |
| character varying [ (n) ] | varchar [ (n) ] | 가변길이 문자열 |
| character [ (n) ] | char [ (n) ] | 고정길이 문자열 |
| cidr | IPv4 또는 IPv6 네트워크 주소 | |
| circle | 평면에서의 원 | |
| date | 달력 날짜 (년, 월, 일) | |
| double precision | float8 | 두배 정밀도의 부동소수점 숫자 |
| inet | IPv4 또는 IPv6 호스트 주소 | |
| integer | int, int4 | 부호 있는 4바이트 정수 |
| interval [ (p) ] | 시간 간격 | |
| line | infinite line in the plane | |
| lseg | line segment in the plane | |
| macaddr | MAC 주소 | |
| money | 통화 화폐 | |
| numeric [ (p, s) ] | decimal [ (p, s) ] | 정밀도를 지정할 수 있는 범용 숫자 |
| path | 평면에서 지리적 경로 | |
| point | 평면에서 지리적 위치 | |
| polygon | 평면에서의 다각형 | |
| real | float4 | 부동소수점 숫자 |
| smallint | int2 | 부호있는 2바이트 정수 |
| serial | serial4 | 자동증가 4바이트 정수 |
| text | 가변 길이 문자열 | |
| time [ (p) ] [ without time zone ] | 시간 | |
| time [ (p) ] with time zone | timetz | 지역시간대를 포함하는 시간 |
| timestamp [ (p) ] [ without time zone ] | 날짜와 시간 | |
| timestamp [ (p) ] with time zone | timestamptz | 지역시간대를 포함하는 날짜와 시간 |
호환성: 다음 자료형들은 SQL에 의해 지정된 것들이다: bit, bit varying, boolean, char, character varying, character, varchar, date, double precision, integer, interval, numeric, decimal, real, smallint, time (with or without time zone), timestamp (with or without time zone).
Each data type has an external representation determined by its input and output functions. Many of the built-in types have obvious external formats. However, several types are either unique to PostgreSQL, such as geometric paths, or have several possibilities for formats, such as the date and time types. Some of the input and output functions are not invertible. That is, the result of an output function may lose accuracy when compared to the original input.