0

Suppose: table_name = t1

Check constraint on column c1 is (Y, N, '').

But when I manually inserted any value in c1 column other than above valid values (like A), database won't give any error and committed successfully.

How do I avoid this?

Peter O.
  • 32,158
  • 14
  • 82
  • 96
Mayur Sharma
  • 65
  • 2
  • 5
  • 17

2 Answers2

0

According to MySQL DocsHERE:

The CHECK clause is parsed but ignored by all storage engines.

An alternative of this is to create a BEFORE INSERT trigger.

John Woo
  • 258,903
  • 69
  • 498
  • 492
0

Assuming "The CHECK clause is parsed but ignored by all storage engines.", I have changed my check constraint to accept only Y and N. I also need to change the code, where i declare and initiallize the variable corresponding to this column.

Thanks for all your replies.

Mayur Sharma
  • 65
  • 2
  • 5
  • 17