Enumeration types and collection types
The value of a field can be selected only in a given range, such as a radio box, a multi-marquee
The enum radio can only select a value within a given range, such as gender sex sex male male/female female
Set multiple selection You can select one or more values within a given range (hobby 1, hobby 2, hobby 3 ...) )
CREATE TABLE consumer (IDint, nameChar( -), Sexenum('male','female'), levelenum('Vip1','VIP2','VIP3'), HobbiesSet('Play','Music','Run') ; insert into consumer values (1,'CMZ','male','Vip1','Music,run'); # because it's not within the selection, insert into consumer values (2,'CMZ','XXX','Vip1','Music,run');
# operation Process MySQL>CREATE TABLE consumer (Idint, NameChar( -), Sexenum('male','female'), Levelenum('Vip1','VIP2','VIP3'), HobbiesSet('Play','Music','Run') - ); Query OK,0Rows Affected (0.03sec) MySQL>INSERT into consumer values(1,'CMZ','male','Vip1','Music,run'); Query OK,1Row affected (0.04sec) MySQL>Select* fromconsumer;+------+------+------+-------+-----------+| ID | name | sex | Level | Hobbies |+------+------+------+-------+-----------+|1| CMZ | Male | Vip1 | Music,run |+------+------+------+-------+-----------+1Rowinch Set(0.00sec) MySQL>INSERT into consumer values(1,'CMZ','XXX','Vip1','Music,run'); ERROR1265(01000): Data truncated forColumn'Sex'At row1
8.3.4-mysql enumeration,