Reputation: 6492
i am new to postgres
how to create table with check constraint for column name say polluted which only have to accept 'yes' or 'no' values on insert.
for other values it should promote error message
My table name is vehicles
Upvotes: 6
Views: 9832
Reputation:
Use an in
condition.
create table vehicles
(
id integer primary key,
polluted text not null check (polluted in ('yes', 'no'))
);
Upvotes: 19