This page in other versions: Unsupported versions: 7.0

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 explicit declared upper limit on the size of the field.

Table 3-5. Postgres Character Types

Character Type Storage Recommendation Description
char 1 byte SQL92-compatible Single character
char(n) (4+n) bytes SQL92-compatible Fixed-length blank padded
text (4+x) bytes Best choice Variable-length
varchar(n) (4+n) bytes SQL92-compatible Variable-length with limit

There is one other fixed-length character type in Postgres. The name type only has one purpose and that is for storage of internal catalog names. It is not intended for use by the general user. Its length is currently defined as 32 bytes (31 characters plus terminator) but should be reference using NAMEDATALEN. The length is set at compile time (and is therefore adjustable for special uses); the default maximum length may change in a future release.

Table 3-6. Postgres Specialty Character Type

Character Type Storage Description
name 32 bytes Thirty-one character internal type

Submit correction

If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.

Privacy Policy | About PostgreSQL
Copyright © 1996-2016 The PostgreSQL Global Development Group