|
char(n)
The term char(n) describes a
datatype.
Like all
character datatypes
char(n) is also compatible to the ANSI-standard.
The values which can be stored in columns defined with char(n), always have the fixed lenght of n (fixed-length character string).
Therefore, independent from the length of a string, the datatype char(n) will always require n
bytes
of storage.
Strings which are longer than n will be cut-off after the nth character.
The range for the variable n is between 1 and 255 (ASE-Version 12.0) and between 1 and 16384
(starting with ASE-Version 12.5). The required storage for a column defined by the datatype char(16) will therefore always be 16 bytes.
Usage of the datatype char(n)
The datatype char(n) can be used to store a fixed number of characters (fixed-length character string) or strings that do not contain more than five characters. Examples can be a post code, insurance or customer number. char(n) should be used if the "character set" to be stored only requires one byte per character, i.e. for singlebyte character sets, like English. So called multibyte character sets, like for example Japanese or Chinese should be stored in columns that have been defined using the
nchar(n)
datatype.
See also:
ASE T-SQL - Aggregate Functions, ascii(), char(), charindex(), char_length(), compare(), difference(), lower(), ltrim(), patindex(), replicate(), reverse(), right(), rtrim(), sortkey(), soundex(), space(), str(), String Functions, stuff(), substring(), to_unichar(), uhighsurr(), ulowsurr(), upper(), uscalar().
|