Oracle 5.0 Reference Manual page 873

Table of Contents

Advertisement

However, this version of the previous
CREATE TABLE sizes (
c1 ENUM('small', CONCAT('med','ium'), 'large')
);
You also may not employ a user variable as an enumeration value. This pair of statements do not work:
SET @mysize = 'medium';
CREATE TABLE sizes (
name ENUM('small', @mysize, 'large')
);
If you wish to use a number as an enumeration value, you must enclose it in quotation marks. If the
quotation marks are omitted, the number is regarded as an index. For this and other reasons—as
explained later in this section—we strongly recommend that you do not use numbers as enumeration
values.
Duplicate values in the definition cause a warning, or an error if strict SQL mode is enabled.
The value may also be the empty string ('') or
• If you insert an invalid value into an
the empty string is inserted instead as a special error value. This string can be distinguished from a
"normal" empty string by the fact that this string has the numeric value 0. More about this later.
If strict SQL mode is enabled, attempts to insert invalid
• If an
column is declared to permit NULL, the
ENUM
the default value is NULL. If an
element of the list of permitted values.
Each enumeration value has an index:
• Values from the list of permissible elements in the column specification are numbered beginning with
1.
• The index value of the empty string error value is 0. This means that you can use the following
statement to find rows into which invalid
SELECT
mysql>
SELECT * FROM tbl_name WHERE enum_col=0;
• The index of the
NULL
• The term "index" here refers only to position within the list of enumeration values. It has nothing to do
with table indexes.
For example, a column specified as
shown here. The index of each value is also shown.
Value
NULL
''
'one'
'two'
'three'
An
column can have a maximum of 65,535 distinct elements. (The practical limit is less than
ENUM
3000.) A table can have no more than 255 unique element list definitions among its
String Types
CREATE TABLE
NULL
(that is, a string not present in the list of permitted values),
ENUM
column is declared
ENUM
value is NULL.
ENUM('one', 'two', 'three')
853
statement does not work:
under certain circumstances:
values result in an error.
ENUM
value is a legal value for the column, and
NULL
NULL, its default value is the first
NOT
values were assigned:
ENUM
can have any of the values
Index
NULL
0
1
2
3
and
ENUM
SET

Advertisement

Table of Contents
loading

This manual is also suitable for:

Mysql 5.0

Table of Contents