0

I am trying to drop a column of a table via PHP (PDO). However there is a foreign key constraint on the column in question.

So I would like to drop the constraints placed on this column along with column.

DBCon::getCon()->query('ALTER TABLE `module_column` DROP COLUMN `module_id`');

How do I drop the foreign key constraints along with the column?

  • You need to drop the constraints first. AFAIK there's no "drop the column with all its constraints" command – simon Nov 10 '16 at 15:32
  • Is there atleast a way to get the constraint names from a specific column? as in a `get all constraints for module_column.module_id` command. – G.G. Joe Nov 10 '16 at 15:34
  • Yes, see this [SO answer](http://stackoverflow.com/a/201678/4681654) – simon Nov 10 '16 at 15:38

0 Answers0