Reputation: 1419
I am new to SQL, and I have a table group with a group_cap column. How do I specify in SQL that column group_cap cannot be a value greater than 4. For example, there cannot be more than 4 people in group A.
Upvotes: 0
Views: 193
Reputation: 668
Create a constraint on the table.
ALTER TABLE [group] ADD CONSTRAINT
CK_group_cap CHECK (group_cap <= 4)
for a range of values, use between
ALTER TABLE [group] ADD CONSTRAINT
CK_group_cap CHECK (group_cap between 1 and 4)
Upvotes: 1