Renaming foreign-key columns in MySQL
AFAIK, dropping the constraint, then rename, then add the constraint back is the only way. Backup first!
AFAIK, dropping the constraint, then rename, then add the constraint back is the only way. Backup first!
As explained here, seems the foreign key constraint has to be dropped by constraint name and not the index name. The syntax is: ALTER TABLE footable DROP FOREIGN KEY fooconstraint;
Lone Ranger is very close… in fact, you also need to specify the datatype of the renamed column. For example: ALTER TABLE `xyz` CHANGE `manufacurerid` `manufacturerid` INT; Remember : Replace INT with whatever your column data type is (REQUIRED) Tilde/ Backtick (`) is optional
You usually get this error if your tables use the InnoDB engine. In that case you would have to drop the foreign key, and then do the alter table and drop the column. But the tricky part is that you can’t drop the foreign key using the column name, but instead you would have to … Read more