Communities for your favorite technologies. Explore all Collectives
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work.
Bring the best of human thought and AI automation together at your work. Learn more
Find centralized, trusted content and collaborate around the technologies you use most.
Stack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
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
boolean
Use an in condition.
in
create table vehicles ( id integer primary key, polluted text not null check (polluted in ('yes', 'no')) );
Add a comment
Required, but never shown
By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.
Start asking to get answers
Find the answer to your question by asking.
Explore related questions
See similar questions with these tags.
booleantype? That would be a much better choice for a yes/no flag