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 | 

NCHAR(n)

Description

Fixed-length character strings are represented as NCHAR(n), where where n is the number of characters. Character strings that can be stored in this data type must belong to the character sets explained earlier. 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 trailing space is filled with space characters. In some language character sets, one character is stored as more than one byte. Therefore, n must not be considered as the byte size.
The locale used by NCHAR is the locale of the operating system, or is specified by the CUBRID_LANG environment variable.

NCHAR(n), NATIONAL CHAR(n) and NATIONAL CHARACTER(n) can be used interchangeably.

Note
  • n must be a number greater than 0.
  • The number of national character sets that can be used in a single database is set to be one. For example, 8-bit ISO 8889-1 (Latin-1) and EUC code sets cannot be used simultaneously in the same database.
  • An error occurs if a non-national character string (whether it is fixed-length or variable-length) is specified for an attribute declared as a national character string.
  • Using two different character code sets at the same time also causes an error.
Example

If you specify N'Härder' as NCHAR(8), 'Härder ' is stored (a 6-character string plus two space characters).
If you specify N'Härder ' as NCHAR(6), 'Härder' is stored (a 6-character string; two space characters are truncated).
If you specify N'Härder' as NCHAR, an error occurs (because the length of the character string is greater than the default value 1).
If you specify 'pacesetter' as NCHAR(12), an error occurs (that is, if a non-national string is specified for an attribute declared as a national character string).