ENUM
and
SET
columns provide an
efficient way to define columns that can contain only a given
set of values. See Section 10.4.4, “The ENUM
Type”, and
Section 10.4.5, “The SET
Type”. However, in MySQL 4.1 and earlier,
ENUM
and
SET
columns do not provide true
constraints on entry of invalid data:
ENUM
columns always have a
default value. If you specify no default value, then it is
NULL
for columns that can have
NULL
, otherwise it is the first
enumeration value in the column definition.
If you insert an incorrect value into an
ENUM
column or if you force
a value into an ENUM
column
with IGNORE
, it is set to the reserved
enumeration value of 0
, which is
displayed as an empty string in string context.
If you insert an incorrect value into a
SET
column, the incorrect
value is ignored. For example, if the column can contain
the values 'a'
, 'b'
,
and 'c'
, an attempt to assign
'a,x,b,y'
results in a value of
'a,b'
.
User Comments
like already metioned: "An ENUM value must be one of those listed ..."
when fetching enum fields eg. to an array:
enum('a','b','c') == array(1=>'a', 2=>'b', 3=>'c')
Add your own comment.