Account
Categories

CHECK Constraint


The CHECK constraint is a type of constraint that is applied only to columns.

It checks whether the values inserted in a column satisfy a specific condition or rule or not.

Here, a condition means any logical expression like age > 0, salary <= 50000, etc.

If someone tries to insert a value that doesn't follow the condition, then it gives an error.

Syntax:

CREATE TABLE table_name (
    column_name data_type,
    CONSTRAINT constraint_name CHECK (condition)
);