SET column type : Set « Data Types « MySQL Tutorial






mysql>
mysql> CREATE TABLE myTable
    -> (
    ->    ID SMALLINT UNSIGNED,
    ->    Model VARCHAR(40),
    ->    Color ENUM('red', 'blue', 'green', 'yellow'),
    ->    Options SET('rack', 'light', 'helmet', 'lock')
    -> );
Query OK, 0 rows affected (0.03 sec)

mysql>
mysql> desc myTable;
+---------+-------------------------------------+------+-----+---------+-------+
| Field   | Type                                | Null | Key | Default | Extra |
+---------+-------------------------------------+------+-----+---------+-------+
| ID      | smallint(5) unsigned                | YES  |     | NULL    |       |
| Model   | varchar(40)                         | YES  |     | NULL    |       |
| Color   | enum('red','blue','green','yellow') | YES  |     | NULL    |       |
| Options | set('rack','light','helmet','lock') | YES  |     | NULL    |       |
+---------+-------------------------------------+------+-----+---------+-------+
4 rows in set (0.00 sec)

mysql>
mysql> drop table myTable;
Query OK, 0 rows affected (0.02 sec)








10.19.Set
10.19.1.SET Type
10.19.2.SET column type
10.19.3.Using the SET type
10.19.4.If you set a SET column to an unsupported value, the value is ignored and a warning is issued
10.19.5.Search for SET values using the FIND_IN_SET() function
10.19.6.Search for SET values using the LIKE operator
10.19.7.Looking for values containing the first set member
10.19.8.MySQL stores SET and ENUM as numbers
10.19.9.Looking for an exact match in a set column