PostgreSQL에서는 사용자들이 쓸 수 있는 많은 기본 자료형을 제공하고 있다. 또한, CREATE TYPE 명령을 이용해서 새로운 자료형을 직접 만들어 사용할 수 있다.
PostgreSQL에서 기본적으로 제공하는 모든 내장 범용 자료형은 표 8-1 목록과 같다. "별칭" 칼럼에 나열된 대체 이름들의 대부분은 PostgreSQL 역사적인 이유로 내부적으로 사용되는 것들이다. 덧붙여, 내부적으로만 사용하는 것이거나, 더 이상 사용되지 않을 옛 자료형들도 있지만, 그것들은 여기서 나열하지 않는다.
표 8-1. 자료형
| 이름 | 별칭 | 설명 |
|---|---|---|
| bigint | int8 | 부호 있는 8바이트 정수형 |
| bigserial | serial8 | 자동 증가 8바이트 정수형 |
| bit [ (n) ] | 고정 길이 비트 문자열 | |
| bit varying [ (n) ] | varbit | 가변 길이 비트 문자열 |
| boolean | bool | 논리 불린형 (참/거짓) |
| box | 평면 위 직각사각형 | |
| bytea | 이진자료 ("바이트 배열") | |
| character varying [ (n) ] | varchar [ (n) ] | 가변 결이 문자열 |
| character [ (n) ] | char [ (n) ] | 고정 길이 문자열 |
| cidr | IPv4 또는 IPv6 네트워크 주소 | |
| circle | 평면 위 원 | |
| date | 달력 날짜 (년, 월, 일) | |
| double precision | float8 | 2배 정밀 부동 소수형 (8 바이트) |
| inet | IPv4 또 IPv6 호스트 주소 | |
| integer | int, int4 | 부호 있는 4바이트 정수형 |
| interval [ fields ] [ (p) ] | 시간 간격 | |
| line | 평면 위 무한 직선 | |
| lseg | 평면 위 선분 | |
| macaddr | MAC (매체 접근 제어) 주소 | |
| money | 화폐형 | |
| numeric [ (p, s) ] | decimal [ (p, s) ] | 정밀도 선택 가능한 숫자형 |
| path | 평면 위 기하학적 경로 | |
| point | 평면 위 기하학적 위치 | |
| polygon | 평면 위 기하학적 닫힌 경로 | |
| real | float4 | 부동소수형 (4 바이트) |
| 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 | 지역시간대를 포함한 날짜와 시각 |
| tsquery | 텍스트 검색 쿼리 | |
| tsvector | 텍스트 검색 문서 | |
| txid_snapshot | 사용자-수준 트랜잭션 ID 스냅샷 | |
| uuid | 범용 고유 식별자 | |
| xml | XML 자료 |
호환성: The following types (or spellings thereof) are specified by SQL: bigint, 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), xml.
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 possible formats, such as the date and time types. Some of the input and output functions are not invertible, i.e., the result of an output function might lose accuracy when compared to the original input.