Open Source RDBMS - Seamless, Scalable, Stable and Free

한국어 | Login |Register

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



Variable-length character strings are represented as VARCHAR(n), where n represents the number of characters. If n is not specified, the value is specified as 1,073,741,823, the maximum length.

When the length of a character string exceeds n, they are truncated. When character string which is shorter than n is stored, whitespace characters are used to fill up the trailing space; for VARCHAR(n), the length of string used are stored. 

VARCHAR(n), CHARACTER, VARYING(n), and CHAR VARYING(n) are used interchangeably.

Note In the earlier versions of CUBRID 9.0, n represents bite length, not the number of characters.

  • STRING is the same as the VARCHAR (maximum length).
  • n is an integer between 1 and 1,073,741,823 (1G).
  • Empty quotes (' ') are used to represent a blank string. In this case, the return value of the LENGTH function is not 0.
Example 1

If you specify 'pacesetter' as CHAR(4), 'pace' is stored (truncated as the length of the character string is greater than 4).

If you specify 'pacesetter' as VARCHAR(12), 'pacesetter' is stored (a 10-character string).

If you specify 'pacesetter ' as VARCHAR(12), 'pacesetter ' is stored (a 10-character string plus two whitespace characters).

If you specify 'pacesetter ' as VARCHAR(10), 'pacesetter' is stored (a 10-character string; two whitespace characters are truncated).

If you specify 'p ' as VARCHAR, 'p' is stored (if n is not specified, the default value 1,073,741,823 is used, and the trailing space is not filled with whitespace characters).

Example 2

If you specify '큐브리드' as VARCHAR(10) in the EUC-KR encoding, it is processed normally.

If you specify '큐브리드' as CHAR(10) and then use CHAR_LENGTH() function in the EUC-KR encoding, 8 is stored.

If you specify '큐브리드, as CHAR(10) in the utf-8 encoding, the last character is broken (one Korean character takes up three bytes in the UTF-8 encoding so it requires two more bytes).

If you specify '큐브리드' as VARCHAR(12) in the UTF-8 encoding, it is processed normally.