All Products
Search
Document Center

Overview of character data types

Last Updated: Jun 18, 2021

Character data types store character (alphanumeric) data, which are words and free-form text, in the database character set or national character set. Character data types are subject to more limits than other data types. Therefore, character data types have fewer attributes.

Character data is stored in strings with byte values that correspond to one of the character sets. The character sets are specified when a database is created. ApsaraDB for OceanBase supports both single-byte and multibyte character sets.

Note

The columns of character data types can store all alphanumeric values. But the columns of NUMBER data types can store only numeric values.

Data type

Length

Description

Length description

CHAR(size [BYTE | CHAR])

Fixed length

High index efficiency. The program uses the trim function to remove white spaces.

Set the size parameter to a numeric value between 1 and 2000. The number of bytes for storage is the value of the size parameter.

NCHAR[(size)]

Fixed length

Use the Unicode character set. Two bytes are required to represent all characters.

Set the size parameter to a numeric value between 1 and 2000. The number of bytes for storage is twice the value of the size parameter.

NVARCHAR2(size)

Variable length

Use the Unicode character set. Two bytes are required to represent all characters.

Set the size parameter to a value between 1 and 32767. The number of bytes for storage is twice that of input characters.

VARCHAR2(size [BYTE | CHAR])

Variable length

Use the Unicode character set. Two bytes are required to represent all characters.

Set the size parameter to a numeric value between 1 and 32767. The number of bytes for storage is that of bytes for input characters rather than the value of the size parameter.

VARCHAR(size [BYTE | CHAR])

Variable length

In ApsaraDB for OceanBase, VARCHAR functions the same as VARCHAR2.

Set the size parameter to a numeric value between 1 and 32767. The number of bytes for storage is that of bytes for input characters rather than the value of the size parameter.

You must specify the length semantics for the CHAR and VARCHAR2 data types. The default length semantics is defined by the NLS_LENGTH_SEMANTICS system variable.