Loading

MYSQLSET Data Type

SET Data Type:- MYSQL SET is a data type string object which can hold zero or more value. 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.

Share with:


Leave a Reply

Connect with:





z35W7z4v9z8w