-1

I created a

CONSTRAINT chk_donate CHECK credit_card_no LIKE '[0-9][0-9][0-9][0-9][0-9][0-9][0-9]'

but with using an insert query to column name 'credit_card_no' with a numeric datatype with letters, there's no error and the value is 0. Please help.

Aleksei Matiushkin
  • 119,336
  • 10
  • 100
  • 160
NewCoder
  • 33
  • 6

2 Answers2

6

Currently (MySQL 5.7.x) the CHECK clause is ignored by MySQL, see manual, CREATE TABLE:

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

VMai
  • 10,156
  • 9
  • 25
  • 34
0

This is because of your CHECK method.The latest versions of mysql uses CREATE TABLE method instead of CHECK..Changing CHECK to CREATE TABLE or you can use TRIGGER as mentioned here

Community
  • 1
  • 1
Avinash Babu
  • 6,171
  • 3
  • 21
  • 26