Why I got this error: "SQL Error 1025: Error on rename of '...' to '...' (errno: 150)"?

4.8k views Asked by At

I want to rename a field of a table in MySQL ver 5.2.25, from "alter table", but I got this error:

SQL Error 1025: Error on rename of '.\Packers\#sql-804_3' to '.\Packers\pattern' (errno: 150)

but on other table I had not this problem, I don't know why, is it caused by foreign key?

1

There are 1 answers

2
Marc B On

Yes, it's a foreign key error. Do show innodb status immediately after your alter table attempt, and part of the output will be the last foreign key error details.

Generally it's caused by a data type mismatch on the foreign key fields (it's 'int' in one table but 'bigint' in your alter table, or one's unsigned and the other's not, etc...)