Inserting data to ENUM type column : ENUM « Data Types « MySQL Tutorial






mysql>
mysql>
mysql> CREATE TABLE Classes
    -> (
    ->    ClassID SMALLINT NOT NULL PRIMARY KEY,
    ->    Dept CHAR(4) NOT NULL,
    ->    Level ENUM('Upper', 'Lower') NOT NULL,
    ->    TotalStudents TINYINT UNSIGNED NOT NULL
    -> );
Query OK, 0 rows affected (0.05 sec)

mysql>
mysql>
mysql> INSERT INTO Classes VALUES (1001, 'ANTH', 'Upper', 25),
    ->                            (1002, 'ANTH', 'Upper', 25),
    ->                            (1003, 'MATH', 'Upper', 18),
    ->                            (1004, 'ANTH', 'Lower', 19),
    ->                            (1005, 'ENGL', 'Upper', 28),
    ->                            (1006, 'MATH', 'Lower', 23),
    ->                            (1007, 'ENGL', 'Upper', 25),
    ->                            (1008, 'MATH', 'Lower', 29),
    ->                            (1009, 'ANTH', 'Upper', 25),
    ->                            (1010, 'ANTH', 'Lower', 30),
    ->                            (1011, 'ENGL', 'Lower', 26),
    ->                            (1012, 'MATH', 'Lower', 22),
    ->                            (1013, 'ANTH', 'Upper', 27),
    ->                            (1014, 'ANTH', 'Upper', 21),
    ->                            (1015, 'ENGL', 'Lower', 25),
    ->                            (1016, 'ENGL', 'Upper', 32);
Query OK, 16 rows affected (0.01 sec)
Records: 16  Duplicates: 0  Warnings: 0

mysql>
mysql>
mysql> select * from Classes;
+---------+------+-------+---------------+
| ClassID | Dept | Level | TotalStudents |
+---------+------+-------+---------------+
|    1001 | ANTH | Upper |            25 |
|    1002 | ANTH | Upper |            25 |
|    1003 | MATH | Upper |            18 |
|    1004 | ANTH | Lower |            19 |
|    1005 | ENGL | Upper |            28 |
|    1006 | MATH | Lower |            23 |
|    1007 | ENGL | Upper |            25 |
|    1008 | MATH | Lower |            29 |
|    1009 | ANTH | Upper |            25 |
|    1010 | ANTH | Lower |            30 |
|    1011 | ENGL | Lower |            26 |
|    1012 | MATH | Lower |            22 |
|    1013 | ANTH | Upper |            27 |
|    1014 | ANTH | Upper |            21 |
|    1015 | ENGL | Lower |            25 |
|    1016 | ENGL | Upper |            32 |
+---------+------+-------+---------------+
16 rows in set (0.00 sec)

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








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