All Products
Search
Document Center

PolarDB:Character types

Last Updated:Mar 28, 2026

PolarDB for PostgreSQL (Compatible with Oracle) supports the following character types for storing text data.

Supported types

TypeDescription
CHAR[(n)]Fixed-length string, space-padded to n characters. Default n is 1.
CLOBLarge variable-length string. Maximum size: ~1 GB.
LONGVariable-length string with unlimited length.
NVARCHAR(n)Variable-length string with a limited length.
NVARCHAR2(n)Variable-length string with a limited length.
STRINGAlias for VARCHAR2.
VARCHAR(n)Variable-length string with a limited length. Provided for compatibility; use VARCHAR2 instead.
VARCHAR2(n)Variable-length string with a limited length.
TEXTLarge variable-length string. Maximum size: ~1 GB.

In all types that accept n, n must be a positive integer specifying the maximum string length in characters. Assigning a string longer than n raises an error, unless the excess characters are all spaces — in that case, the string is silently truncated to n.

CHAR

CHAR(n) stores a fixed-length string. Strings shorter than n are padded with trailing spaces to reach exactly n characters.

Trailing spaces are insignificant in comparisons between CHAR values and are stripped when a CHAR value is cast to another string type. Explicitly casting an over-length value to CHAR(n) truncates it to n characters without raising an error, consistent with the SQL standard.

VARCHAR, VARCHAR2, NVARCHAR, and NVARCHAR2

These types store strings at their actual length without padding. Unlike CHAR, trailing spaces in VARCHAR values are significant — two values that differ only in trailing spaces are not considered equal.

Explicitly casting an over-length value to VARCHAR(n) truncates it to n characters without raising an error, consistent with the SQL standard.

CLOB

CLOB stores large text values. It is equivalent to VARCHAR2 in semantics except that no length limit is specified for CLOB. Use CLOB when the maximum string length is not known in advance. Maximum size is approximately 1 GB.

TEXT

TEXT stores variable-length strings with no declared limit and a maximum size of approximately 1 GB. The CLOB type is similar to TEXT and its length is unlimited.

Storage

The storage overhead for character data depends on string length:

  • Strings shorter than 127 bytes: 1 byte of overhead plus the actual string.

  • Strings 127 bytes or longer: 4 bytes of overhead plus the actual string.

For CHAR(n), trailing spaces count toward storage. Long strings are compressed automatically, so actual disk usage may be less than the raw size. Long values are stored in background tables and do not affect read performance for shorter column values.

The database character set determines the encoding used for all textual values.