String Data Types

PostgreSQL includes three basic data types for storing string-related data. In compliance with the SQL standard, there are types for fixed-length and variable-length character strings. Additionally, PostgreSQL defines a more generic data type named TEXT that requires no specified upper limit regarding maximum size. However, this data type is PostgreSQL-specific and is not compliant with the SQL-92 standards.

CHAR (or CHARACTER)

Description

Holds a fixed-length string specified with a maximum length.

Inputs
CHAR(n) 

n—Integer length of string (if omitted, a 1 is assumed).

Storage Size

(4+n) bytes

Notes

CHAR is a SQL-92-compatible data type. Data that does not fill to the limit specified is blank padded.

TEXT

Description ...

Get PostgreSQL Essential Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.