MySQL/tasks/03-set-and-enums.sql

21 lines
529 B
SQL

CREATE SCHEMA task03;
USE task03;
CREATE TABLE Colors (
colorName SET ('red', 'green', 'blue')
);
/* can have multiple values at once and be empty */
INSERT INTO Colors VALUES ('red');
INSERT INTO Colors VALUES ('green');
INSERT INTO Colors VALUES ('blue,green');
INSERT INTO Colors VALUES ('');
CREATE TABLE Animals (
name ENUM ('Dog', 'Cat', 'Bird')
);
/* cannot be empty or multiple variants at once */
INSERT INTO Animals VALUES ('Dog');
INSERT INTO Animals VALUES ('Cat');
INSERT INTO Animals VALUES ('Bird');