Oracle 5.0 Reference Manual page 852

Table of Contents

Advertisement

A fixed-length string that is always right-padded with spaces to the specified length when stored.
represents the column length in characters. The range of
Note
Trailing spaces are removed when
Before MySQL 5.0.3, a
smallest
type that can hold values of the given length. For example,
TEXT
to TEXT, and
CHAR(200000)
column to become a variable-length column, and also affects trailing-space removal.
In MySQL 5.0.3 and later, a
mysql>
CREATE TABLE c1 (col1 INT, col2 CHAR(500));
ERROR 1074 (42000): Column length too big for column 'col' (max = 255);
use BLOB or TEXT instead
is shorthand for CHARACTER.
CHAR
standard SQL way to define that a
4.1 and up uses
utf8
The
data type is an alias for the
CHAR BYTE
MySQL permits you to create a column of type CHAR(0). This is useful primarily when you have to
be compliant with old applications that depend on the existence of a column but that do not actually
use its value.
CHAR(0)
column that is defined as
and
(the empty string).
''
[NATIONAL] VARCHAR(M) [CHARACTER SET charset_name] [COLLATE
collation_name]
A variable-length string.
the range of
is 0 to 255 before MySQL 5.0.3, and 0 to 65,535 in MySQL 5.0.3 and later. The
M
effective maximum length of a
size (65,535 bytes, which is shared among all columns) and the character set used. For example,
characters can require up to three bytes per character, so a
utf8
character set can be declared to be a maximum of 21,844 characters. See
utf8
"Limits on Table Column Count and Row
MySQL stores
VARCHAR
indicates the number of bytes in the value. A
no more than 255 bytes, two length bytes if values may require more than 255 bytes.
Note
Before 5.0.3, trailing spaces were removed when
stored, which differs from the standard SQL specification.
Prior to MySQL 5.0.3, a
to the smallest
TEXT
converted to TEXT, and
affects trailing-space removal.
is shorthand for
VARCHAR
to define that a
VARCHAR
uses
as this predefined character set.
utf8
shorthand for
NATIONAL
String Type Overview
column with a length specification greater than 255 is converted to the
CHAR
is converted to MEDIUMTEXT. However, this conversion causes the
length greater than 255 is illegal and fails with an error:
CHAR
NATIONAL CHAR
column should use some predefined character set. MySQL
CHAR
as this predefined character set.
is also quite nice when you need a column that can take only two values: A
occupies only one bit and can take only the values
CHAR(0) NULL
represents the maximum column length in characters. In MySQL 5.0,
M
in MySQL 5.0.3 and later is subject to the maximum row
VARCHAR
Size".
values as a 1-byte or 2-byte length prefix plus data. The length prefix
column with a length specification greater than 255 is converted
VARCHAR
type that can hold values of the given length. For example,
VARCHAR(200000)
CHARACTER
VARYING.
column should use some predefined character set. MySQL 4.1 and up
VARCHAR.
832
is 0 to 255. If
M
values are retrieved.
CHAR
(or its equivalent short form, NCHAR) is the
Section 10.1.3.6, "National Character
data type. This is a compatibility feature.
BINARY
VARCHAR
column uses one length byte if values require
VARCHAR
is converted to MEDIUMTEXT. However, this conversion
NATIONAL VARCHAR
Section 10.1.3.6, "National Character
is omitted, the length is 1.
M
is converted
CHAR(500)
column that uses the
Section E.7.4,
values were
VARCHAR
VARCHAR(500)
is the standard SQL way
Set".
NVARCHAR
M
Set".
NULL
is
is

Advertisement

Table of Contents
loading

This manual is also suitable for:

Mysql 5.0

Table of Contents