I've got problem with dropping foreign key index, I always get the same error
ALTER TABLE `comments` DROP INDEX `id_user`
which outputs
1025 - Error on rename of './postuj_cz1/#sql-d834_a0c704'
to './postuj_cz1/comments' (errno: 150)
The id_user
on the other table is simple primary key index.
I'm using MySQL version 5.0.85
There are other causes too. For example I had a unique index involving two separate foreign key columns. I had to drop the foreign keys in question before I could drop the unique index. (And obviously you can add the foreign keys back afterward.)
INNODB : this could be as simple as removing the Relation before dropping the Index.
The index is for an foreign key on 'user' table, so In first, try this command:
Find the name of the constraint corresponding to the index on the foreign key,
and after that, try the command:
WARNING: If you try to drop the foreign key with the foreign key name, you will have an error to!
According to this link, the error relates to the definition of the primary key field. The error isn't about the foreign key index.
Check the primary key for the
COMMENTS
table to make sure it does not have theUNSIGNED
keyword while theCOMMENTS.id_user
foreign key had the UNSIGNED keyword. This keyword was causing the problem - inconsistent type of field.To fix, add the
UNSIGNED
keyword to the primary key definition for theCOMMENTS
table. Or remove theUNSIGNED
keyword from the foreign key definition...