Open Source RDBMS - Seamless, Scalable, Stable and Free

한국어 | Login |Register

Versions available for this page: CUBRID 8.2.1 |  CUBRID 8.3.0 |  CUBRID 8.3.1 |  CUBRID 8.4.0 |  CUBRID 8.4.1 |  CUBRID 8.4.3 |  CUBRID 9.0.0 | 

CHAR(n)

Description

Fixed-length character strings are represented as CHAR(n), where n is the number of ASCII character strings. Each character takes up one byte. If n is not specified, the length is set to the default value 1. When the length of a character string exceeds n, the exceeding characters are truncated if they are space characters, or processed as an error otherwise. When a character string shorter than n is stored, the remainder of the character string is filled with space characters.

CHAR(n) and CHARACTER(n) can be used interchangeably.

Note
  • The CHAR data type is always based on the ISO 8859-1 (Latin-1) character set.
  • n must be a number greater than 0.
  • Space characters used as filling characters are considered to be smaller than any other characters, including special characters.
Example

If you specify 'pacesetter' as CHAR(12), 'pacesetter ' is stored (a 10-character string plus two space characters).
If you specify 'pacesetter ' as CHAR(10), 'pacesetter' is stored (a 10-character string; two space characters are truncated).
If you specify 'pacesetter' as CHAR(4), an error occurs (because the length of the character string is greater than 4).
If you specify 'p ' as CHAR, 'p' is stored (if n is not specified, the length is set to the default value 1).