I want to remove constraints from my table. My query is:
ALTER TABLE `tbl_magazine_issue`
DROP CONSTRAINT `FK_tbl_magazine_issue_mst_users`
<
I had the same problem and I got to solve with this code:
ALTER TABLE `table_name` DROP FOREIGN KEY `id_name_fk`;
ALTER TABLE `table_name` DROP INDEX `id_name_fk`;
There is no such thing as DROP CONSTRAINT
in MySQL. In your case you could use DROP FOREIGN KEY
instead.
There is no DROP CONSTRAINT
In MySql. This work like magic in mysql 5.7
ALTER TABLE answer DROP KEY const_name;
this will works on MySQL to drop constraints
alter table tablename drop primary key;
alter table tablename drop foreign key;
If the constraint is not a foreign key, eg. one added using 'UNIQUE CONSTRAINT (colA, colB)' then it is an index that can be dropped using ALTER TABLE ... DROP INDEX ...
Also nice, you can temporarily disable all foreign key checks from a mysql database:
SET FOREIGN_KEY_CHECKS=0;
And to enable it again:
SET FOREIGN_KEY_CHECKS=1;