Home

Data types

Enums

Use enums to represent a fixed set of options (rather than varchar):

CREATE TABLE shirts (name varchar(20), size ENUM ('small', 'medium', 'large'));
INSERT INTO shirts VALUES ('frank', 'medium');
SELECT * FROM shirt WHERE size = 'medium';
CINF 201 material by Joshua Eckroth is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License. Source code for this website available at GitHub.