8. 자료형

차례
8.1. 숫자 자료형
8.1.1. Integer Types
8.1.2. Arbitrary Precision Numbers
8.1.3. Floating-Point Types
8.1.4. Serial Types
8.2. Monetary Types
8.3. Character Types
8.4. Binary Data Types
8.5. Date/Time Types
8.5.1. Date/Time Input
8.5.2. Date/Time Output
8.5.3. Time Zones
8.5.4. Internals
8.6. Boolean Type
8.7. Geometric Types
8.7.1. Points
8.7.2. Line Segments
8.7.3. Boxes
8.7.4. Paths
8.7.5. Polygons
8.7.6. Circles
8.8. Network Address Types
8.8.1. inet
8.8.2. cidr
8.8.3. inet vs. cidr
8.8.4. macaddr
8.9. Bit String Types
8.10. Arrays
8.10.1. Declaration of Array Types
8.10.2. Array Value Input
8.10.3. Accessing Arrays
8.10.4. Modifying Arrays
8.10.5. Searching in Arrays
8.10.6. Array Input and Output Syntax
8.11. Composite Types
8.11.1. Declaration of Composite Types
8.11.2. Composite Value Input
8.11.3. Accessing Composite Types
8.11.4. Modifying Composite Types
8.11.5. Composite Type Input and Output Syntax
8.12. Object Identifier Types
8.13. Pseudo-Types
8.14. XML Document Support

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. 자료형

이름별칭설명
bigintint8부호있는 8바이트 정수
bigserialserial8자동증가 8바이트 정수
bit [ (n) ] 고정길이 비트 문자열
bit varying [ (n) ]varbit가변길이 비트 문자열
booleanbool논리적 불린형 (true/false)
box 평면에서 표현되는 사각형
bytea 이진 자료 ("바이트 배열")
character varying [ (n) ]varchar [ (n) ]가변길이 문자열
character [ (n) ]char [ (n) ]고정길이 문자열
cidr IPv4 또는 IPv6 네트워크 주소
circle 평면에서의 원
date 달력 날짜 (년, 월, 일)
double precisionfloat8두배 정밀도의 부동소수점 숫자
inet IPv4 또는 IPv6 호스트 주소
integerint, 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 평면에서의 다각형
realfloat4부동소수점 숫자
smallintint2부호있는 2바이트 정수
serialserial4자동증가 4바이트 정수
text 가변 길이 문자열
time [ (p) ] [ without time zone ] 시간
time [ (p) ] with time zonetimetz지역시간대를 포함하는 시간
timestamp [ (p) ] [ without time zone ] 날짜와 시간
timestamp [ (p) ] with time zonetimestamptz지역시간대를 포함하는 날짜와 시간

호환성: 다음 자료형들은 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.