Innodb foreign key constraints
I am trying to change the type in two tables of an innoDB
. The problem is that the values are a key and a foreign key. When I try to make the change I get the following error
#1025 error on rename
Do I need to drop the foreign keys and the开发者_Python百科n make the changes and then reapply the foreign key?
Since u can use the name to drop the foreign key first and the column then:
ALTER TABLE categories DROP FOREIGN KEY categories_ibfk_1;
ALTER TABLE categories DROP COLUMN assets_id;
To find out which table caused the error you can run
SHOW ENGINE INNODB STATUS\G
and then look at the "LATEST FOREIGN KEY ERROR" section.
Yeah, you have to drop the foreign key. Try SHOW INNODB STATUS
to see if there's a more elaborated explanation of what's going on.
精彩评论