ENUM with default value : ENUM : Data Types MySQL TUTORIALS


MySQL TUTORIALS » Data Types » ENUM »

 

ENUM with default value


mysql>
mysql> CREATE TABLE Employee (
    ->     ID INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
    ->     First_Name VARCHAR(20NOT NULL,
    ->     Last_Name VARCHAR(30NOT NULL,
    ->     Age INT,
    ->     Gender ENUM('M''F'DEFAULT 'F',
    ->     Favorite_Activity ENUM('Programming', 'Eating','Biking', 'Running', 'None') DEFAULT 'None'
    -> );
Query OK, 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    |                |
+-------------------+--------------------------------------------------------+------+-----+---------+----------------+
rows in set (0.01 sec)

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

mysql>



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .

Follow Navioo On Twitter

MySQL TUTORIALS

 Navioo Data Types
» ENUM