You are on page 1of 1

What is the difference between a column constraint and a table constraint?

What is the
purpose of a CHECK constraint?
Ans:-
The difference between column constraint and table constraint is given below:
1. Column constraint applies only to individual columns, whereas table constraints apply to
groups of one or more columns.
2. In a column constraint, the constraint name is not necessary. In a table constraint, the
constraint name is necessary.
3. NOT NULL is permitted in column constraints but not in table constraints.
4. When building a table, a Column constraint is stated, but a table constraint is generated later.
5. At column constraints, composite keys can’t be defined. Composite keys are allowable at
table constraints.
Purpose of a CHECK constraint: A CHECK constraint is a rule that defines the permissible
values for one or more columns in each row of a base table. To restrict the value range that can
be entered into a column, use the CHECK constraint. Only certain values for a single column are
permitted when a CHECK constraint is defined for it. Also, A table's CHECK constraint can be
used to restrict the values in specific columns based on the values of other columns in the same
row.

You might also like