Reputation:
I'm using MySQL 5.1.36 I'm trying to drop a constraint named chk1
but MySQL reports an syntactical error. I looked it up but am unable to find it. What is the error?
mysql> create database house;
Query OK, 1 row affected (0.01 sec)
mysql> use house;
Database changed
mysql> create table member(age integer);
Query OK, 0 rows affected (0.05 sec)
mysql> alter table member add constraint chk1 check(age>0);
Query OK, 0 rows affected (0.08 sec)
Records: 0 Duplicates: 0 Warnings: 0
mysql> alter table member drop constraint chk1;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'constraint chk1' at line 1
mysql> alter table member drop check chk1;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'check chk1' at line 1
Upvotes: 0
Views: 4389
Reputation: 37382
Check constraint is parsed but ignored in Mysql. So you don't need to remove it. You can use enum or triggers to implement desired functionality. In your case you can also change age
to unsigned
.
Upvotes: 1