ENUM with default value : ENUM « Data Types « MySQL Tutorial






mysql>
mysql> CREATE TABLE Employee (
    ->     ID INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
    ->     First_Name VARCHAR(20) NOT NULL,
    ->     Last_Name VARCHAR(30) NOT NULL,
    ->     Age INT,
    ->     Gender ENUM('M', 'F') DEFAULT 'F',
    ->     Favorite_Activity ENUM('Programming', 'Eating','Biking', 'Running', 'None') DEFAULT 'None'
    -> );
Query OK, 0 rows affected (0.05 sec)

mysql>
mysql> desc Employee;
+-------------------+--------------------------------------------------------+------+-----+---------+----------------+
| Field             | Type                                                   | Null | Key | Default | Extra          |
+-------------------+--------------------------------------------------------+------+-----+---------+----------------+
| ID                | int(11)                                                | NO   | PRI | NULL    | auto_increment |
| First_Name        | varchar(20)                                            | NO   |     |         |                |
| Last_Name         | varchar(30)                                            | NO   |     |         |                |
| Age               | int(11)                                                | YES  |     | NULL    |                |
| Gender            | enum('M','F')                                          | YES  |     | F       |                |
| Favorite_Activity | enum('Programming','Eating','Biking','Running','None') | YES  |     | None    |                |
+-------------------+--------------------------------------------------------+------+-----+---------+----------------+
6 rows in set (0.01 sec)

mysql>
mysql> drop table Employee;
Query OK, 0 rows affected (0.00 sec)

mysql>








10.10.ENUM
10.10.1.ENUM Type
10.10.2.Possible value for a ENUM column
10.10.3.ENUM with default value
10.10.4.Use ENUM type column
10.10.5.Inserting data to ENUM type column
10.10.6.Use numeric operation in ENUM type column
10.10.7.If you retrieve an ENUM value in a numeric context, the column value's index is returned