PostgreSQL
PrevChapter 8. Data TypesNext

Character Types

SQL92 defines two primary character types: char and varchar. Postgres supports these types, in addition to the more general text type, which unlike varchar does not require an upper limit to be declared on the size of the field.

Table 8-5. Postgres Character Types

Character TypeStorageRecommendationDescription
char1 byteSQL92-compatibleSingle character
char(n)(4+n) bytesSQL92-compatibleFixed-length blank padded
text(4+x) bytesBest choiceVariable-length
varchar(n)(4+n) bytesSQL92-compatibleVariable-length with limit

There are currently other fixed-length character types. These provide no additional functionality and are likely to be deprecated in the future.

Table 8-6. Postgres Specialty Character Types

Character TypeStorageDescription
char22 bytesTwo characters
char44 bytesFour characters
char88 bytesEight characters
char1616 bytesSixteen characters


PrevHomeNext
Monetary TypeUpDate/Time Types