Insert String value as ENUM
/*
mysql> Drop table Classes;
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.25 sec)
mysql> INSERT INTO Classes
-> VALUES (1001, 'ANTH', 'Upper', 25),
-> (1002, 'ANTH', 'Lower', 25),
-> (1003, 'MATH', 'Upper', 18),
-> (1004, 'ANTH', 'Lower', 19),
-> (1005, 'ENGL', 'Upper', 28);
Query OK, 5 rows affected (0.01 sec)
Records: 5 Duplicates: 0 Warnings: 0
mysql> select * from Classes;
+---------+------+-------+---------------+
| ClassID | Dept | Level | TotalStudents |
+---------+------+-------+---------------+
| 1001 | ANTH | Upper | 25 |
| 1002 | ANTH | Lower | 25 |
| 1003 | MATH | Upper | 18 |
| 1004 | ANTH | Lower | 19 |
| 1005 | ENGL | Upper | 28 |
+---------+------+-------+---------------+
5 rows in set (0.00 sec)
*/
Drop table Classes;
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
);
INSERT INTO Classes
VALUES (1001, 'ANTH', 'Upper', 25),
(1002, 'ANTH', 'Lower', 25),
(1003, 'MATH', 'Upper', 18),
(1004, 'ANTH', 'Lower', 19),
(1005, 'ENGL', 'Upper', 28);
select * from Classes;
Related examples in the same category