SQLMentor // glossary

CHECK Constraint

A CHECK constraint enforces a custom boolean condition on every row inserted or updated, rejecting any value that doesn't satisfy it — for example, guaranteeing a salary is always positive.

Unlike a foreign key (which checks against another table) or a unique constraint (which checks against other rows), a CHECK constraint validates a row against a fixed rule that doesn't depend on any other data.

CHECK constraints can reference multiple columns in the same row, letting you enforce relationships like "end_date must be after start_date" directly in the schema.

Example

ALTER TABLE employees
  ADD CONSTRAINT chk_salary_positive CHECK (salary > 0);