Skip to content

CHECK CONSTRAINT

Check Constraints

The CHECK Constraint enables a condition to check the value being entered into a record. If the condition evaluates to false, the record violates the constraint and isn’t entered the table.

For example, the following program creates a new table called CUSTOMERS and adds five columns. Here, we add a CHECK with AGE column, so that you cannot have any CUSTOMER who is below 18 years.

If the CUSTOMERS table has already been created, then to add a CHECK constraint to AGE  column, you would write a statement like the one given below.

You can also use the following syntax, which supports naming the constraint in multiple columns as well –