Mega Code Archive

 
Categories / MySQL Tutorial / Data Types
 

SET column type

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)