February 2018
Intermediate to advanced
510 pages
16h 10m
English
MySQL provides a data type for which lists of permitted values can be predefined when the table is created. The data type is ENUM. If we want to restrict the user from inserting values outside a range of values, we should define the column of data type ENUM. MySQL encodes the user input string values into numbers for ENUM data types.
ENUM provides the following mentioned benefits:
The following is an example that showcases when ENUM is useful:
mysql> CREATE TABLE subjects ( name VARCHAR(40), stream ENUM('arts', 'commerce', 'science'));mysql> INSERT INTO subjects (name, stream) VALUES ('biology','science'), ('statistics','commerce'), ('history','arts');
mysql> SELECT name, stream ...
Read now
Unlock full access