MYSQL SET Data Type:- MYSQL SET is a data type string object which can hold zero or more values. It must be chosen from the predefine specified value.
A SET column can have a maximum of 64 distinct members.
We cannot use duplicate values because it produces a warning or an error.
When a table will create with SET column values a trailing space will be automatically detected.
SET columns can be assigned a character set and collation.
In our query, we can search SET values using the function FIND_IN_SET() function or the LIKE operator.
The SET data type is similar to the ENUM data type, but where the ENUM data type restricts you to a single member of the set of predefined strings, the SET data type allows you to store any of the values together, from none to all of them.
The MySQL SET datatype is stored as an integer or numeric value and it occupies from one to eight bytes in the MySQL table.
For Example:-
CREATE TABLE car(
carid INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
color SET (Red, Black, White, Blue),
);
Note:- SET data type is not normalized.
Note:- The MySQL SET data type allows us to compare multiple values without using complex JOIN operations.
Note:- In MySQL, the SET element is stored in the bitmap where each member is represented by a single bit value.
Read Also:-
BIT MySQL Data Type
TINYINT, SMALLINT, MEDIUMINT, INT, BIGINT MySQL Data Type
BOOLEAN, FLOAT, DOUBLE, DECIMAL MYSQL Data Type
CHAR and VARCHAR MySQL Data Type
ENUM MySQL Data Type
MySQL BINARY and VARBINARY Data Type
For more detail about Data Type, Please visit Mysql Manual