A constraint defines a condition that restricts the values that can be stored in a table. When you insert and update column values, the constraint checks the values against the conditions specified by the constraint. If a value violates the constraint, SQL generates an error message and the statement fails (either when the INSERT, UPDATE, or DELETE statement executes, or when the next COMMIT statement executes depending on when SQL evaluates the constraint). You specify constraints in CREATE and ALTER TABLE statements. Optionally, you supply a name for the constraints following the CONSTRAINT keyword.