0
create table demo (
    ID int,
    Name varchar(255),
    age int,
    CONSTRAINT CHK_DEMO CHECK (age>=18)
);

But When I Insert values in Table like this

mysql> insert into demo (ID,Name,age) value ('5', 'DON',15);

OUTPUT IS:

Query OK, 1 row affected (0.02 sec)
Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786
Sachin from Pune
  • 656
  • 8
  • 19

1 Answers1

1

As explained in the documentation:

 - CHECK

The `CHECK` clause is parsed but ignored by all storage engines. See Section 1.8.2.3, “Foreign Key Differences”.

This is also true of the explicit constraint definition as well.

In other words, MySQL supports the syntax of check constraints. But, MySQL does not actually implement them. They do nothing.

Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786