0

First I made a table. The table is created successfully and there was no error.

CREATE TABLE registered_customer(
Serial_Number INT PRIMARY KEY AUTO_INCREMENT,
Customer_Name VARCHAR(33) UNIQUE,
Mobile_Number INT,
Credit_Card_Number VARCHAR(33) CHECK(Credit_Card_Number LIKE('A[0-9][a-z]' OR 'B[0-9][a-z]')),
City VARCHAR(33) DEFAULT 'Dhaka' CHECK(City IN('Dhaka','Rajshahi','Khulana')),
Date_And_Time TIMESTAMP DEFAULT CURRENT_TIMESTAMP() ) 

Check constraints do not work in MySQL. Am I right or I have a problem in my MySQL configuration?

andy
  • 2,002
  • 1
  • 12
  • 21
Md Shahriar
  • 2,072
  • 22
  • 11
  • possible duplicate of [CHECK constraint in MySQL is not working](http://stackoverflow.com/questions/2115497/check-constraint-in-mysql-is-not-working) – andy Nov 03 '14 at 21:21

2 Answers2

1

From the mysql documentation:

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

So no, CHECK does not work on MySQL.

andy
  • 2,002
  • 1
  • 12
  • 21
0

Correct. CHECK constraints do not work in MySQL:

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

(http://dev.mysql.com/doc/refman/5.6/en/create-table.html)

John Bollinger
  • 160,171
  • 8
  • 81
  • 157