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 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. The name type only has one purpose and that is to provide Postgres with a special type to use for internal names. It is not intended for use by the general user. It's length is currently defined as 32 chars but should be reference using NAMEDATALEN. This is set at compile time and may change in a future release.
Table 8-6. Postgres Specialty Character Type
Character Type | Storage | Description |
---|---|---|
name | 32 bytes | Thirty-two character internal type |