Reputation: 1531
I have an table which look like:
CREATE TABLE MyTable
(
id INTEGER PRIMARY KEY,
type CHAR(1)
);
I already know that the column type
will only have four possible value "a", "b", "c" or "d".
Is there a way to limit the possible value of the column to those four or do I need to do it from my code rather than in SQL?
Upvotes: 0
Views: 485
Reputation: 50173
Add check constraint :
ALTER TABLE MyTable
MODIFY type CHAR(1) NOT NULL CHECK (type in ('a', 'b', 'c', 'd'));
Upvotes: 2