name varchar(50) ,
sex enum('male' , 'female' , 'both' , 'unknow')
The name field can be inserted into any string. name 字段可以插入任意字符串。
sex 字段只允许插入 male , female , both , unknow 中的其中之一,不在范围内的值会报错。
enum 相比较 varchar
The sex field only allows one of male, female, both, unknown to be inserted. Values that are not within the range will report an error.
enum is more standardized compared to varchar, and you can also limit it in the program. 🎜
🎜For performance comparison, I have to wait for the experts to answer...🎜
The underlying storage method of enum is integer type For example, such a field sex enum('male', 'female', 'both', 'unknow') When querying where sex='male' and where sex=1 are equivalent
For example, the following two fields:
The
name
field can be inserted into any string.name
字段可以插入任意字符串。sex
字段只允许插入male , female , both , unknow
中的其中之一,不在范围内的值会报错。
Theenum
相比较varchar
sex
field only allows one ofmale, female, both, unknown
to be inserted. Values that are not within the range will report an error.enum
is more standardized compared tovarchar
, and you can also limit it in the program. 🎜 🎜For performance comparison, I have to wait for the experts to answer...🎜The advantage of Enum is that the value can be within several value ranges
The speed of querying string and enum is almost the same. It is logical to use enum or set. . .
The underlying storage method of enum is integer type
For example, such a field
sex enum('male', 'female', 'both', 'unknow')
When querying
where sex='male'
and where sex=1 are equivalent