I want to create a column element_type in a table (called discussion) that allows the text values \"lesson\" or \"quiz\" but will generate an error if
element_type
discussion
You could add a CHECK CONSTRAINT:
ALTER TABLE distributors ADD CONSTRAINT check_types CHECK (element_type = 'lesson' OR element_type = 'quiz');
Although IMO the cleaner option would be to create an ENUM:
CREATE TYPE element_type AS ENUM ('lesson', 'quiz');