CHECK
CHECK is a SQL statement in the Constraints category. Validates data against a boolean expression. Supported in PostgreSQL, MySQL 8+, but NOT in MySQL 5.7. The syntax is CONSTRAINT name CHECK (condition). It returns constraint. A typical example: CREATE TABLE products ( price DECIMAL(10,2), CONSTRAINT price_check CHECK (price >= 0) ); -- Prevents negative prices A close relative is PRIMARY KEY, which a column or set of columns that uniquely identifies each row. Only one PK per table. Automatically creates a unique index. A close relative is FOREIGN KEY, which ensures referential integrity: values in this column must exist in the referenced parent table. A close relative is UNIQUE, which ensures all values in a column (or combination) are unique across the table. Allows NULLs (multiple NULLs allowed). More about this category: Table constraints — PRIMARY KEY, FOREIGN KEY, UNIQUE, NOT NULL, CHECK, DEFAULT. Related Constraints entries: PRIMARY KEY, FOREIGN KEY, UNIQUE, NOT NULL, DEFAULT, EXCLUDE CONSTRAINT, PRIMARY KEY (Composite), FOREIGN KEY ON DELETE SET NULL.