Character types are required any time that you wish to reference character data, such as blocks of ascii text. They are commonly used for storing names, addresses, and so on.

SQL provides two character types called character , and character varying . In addition to these, a general text type is supported by PostgreSQL, which does not require an explicitly declared upper limit on the size of the field. This means that using the text type does not require you to specify the largest length that you want a value in that column to be as the standard character types do. Columns of type text are automatically re-sized according to the data you put in them, and they may re-size without boundaries (discounting, of course, the 1GB limit for a single field).

Table 3-11. Character Types




character(n) , char(n)

(4+n) bytes

A fixed-length character string, padded up to n characters

character varying(n) , varchar(n)

(4+n) bytes

A variable-length character string with a limit of n characters


(4+n) bytes

A variable, unlimited-length character string

The n in the section called Character Types represents an arbitrarily specified number of characters. This number is specified for a column when a table is created.

Note Text Portability

Although the text data type is not part of the ANSI/ISO SQL standards, many other Relational Database Management Systems (RDBMS) provide this functionality, including Sybase and MS SQL Server.