In MySQL, CHECK constraint allows us to limit the value range that can be inserted in a column.
If you define a CHECK constraint on a single column, we can insert only certain values in this column.
If you define a CHECK constraint on a table it allows us to limit the values that can be inserted in certain columns based on values in other columns in the row.
Here is an example of how to limit the values to less than 18 in Age column:
CREATE TABLE Persons (
ID int NOT NULL,
LastName varchar(255) NOT NULL,
If you want to learn MySQL from top professionals, I recommend this SQL Course by Intellipaat.
Also, watch this video on MySQL: