Tumblelog by Soup.io
Newer posts are loading.
You are at the newest post.
Click here to check if anything new just came in.
lfittl

MySQL error 1025: Error on rename .. (errno: 152)

You are trying to delete a column in a table using:

ALTER TABLE sometable DROP foreign_something;

And MySQL gives you a strange error message like this:

ERROR 1025 (HY000): Error on rename of './somedatabase/sometable' to './somedatabase/#sql2-4aab-71' (errno: 152)

Turns out, the MySQL query parser thinks you want to delete a foreign key, because the column name starts with "foreign", and you didn't escape it properly.

ALTER TABLE sometable DROP `foreign_something`;
or ALTER TABLE sometable DROP COLUMN foreign_something;

works just fine.