Data blog — data types RSS

Enum data type in MySQL

While investigating features of MySQL database engine, I came across an interesting concept: the enum data type.   The enum data type allows for defining static data ranges that can be used as values of certain attributes. These ranges typically are quite small - for example marital status consists of 'Married', 'Single', 'Widowed', 'Divorced', 'N/A' . These five values can be encoded as an enum data type column. For example, we can define a table in the following way. create table Person ( FirstName varchar(50) not null, SurName varchar(50) not null, MaritalStatus enum ('Married', 'Single', 'Widowed', 'Divorced', 'N/A') not null ); Please note this is a very simplified code. Enum in MySQL has a certain feature - the values in rows...

Continue reading