|
Ispirer SQLWays Database Migration Software
CHAR, NCHAR and VARCHAR
[NATIONAL]CHAR[(n)] [BINARY]
A fixed-length character data. The range of n is 0 to 255 characters (1 to 255 prior to MySQL Version 3.23). When n is not specified the default value is 1.
When CHAR values are stored, they are right-padded with spaces to the specified length. When CHAR values are retrieved, trailing spaces are removed. BINARY keyword is given to sort and compare CHAR values in case-sensitive manner. NATIONAL CHAR (or NCHAR) is used to define that a CHAR column should use the default CHARACTER set. This is the default in MySQL.
If the column is defined as CHAR(0) and nullable then the column will occupy only one bit and can take two values: NULL or "" (empty string).
[NATIONAL] VARCHAR(n) [BINARY]
A variable-length string. The range of n is 0 to 255 characters (1 to 255 prior to MySQL Version 4.0.2). Value is stored in database using only as many characters as it contains, plus one byte to record the length.
When the value is stored trailing spaces are removed.
BINARY keyword is given to sort and compare VARCHAR values in case-sensitive manner.