ERROR 1025 (HY000): Error on rename of ‘./TESTDB/ORDERS’ to ‘./TESTDB/#sql2-3b5b-8’

Asked By 0 points N/A Posted on -
qa-featured

I have this code to remove the FOREIGN KEY.

ALTER TABLE ORDERS DROP FOREIGN KEY CUSTOMERID;

When I try to run the code an error message appears:

ERROR 1025 (HY000): Error on rename of './TESTDB/ORDERS' to './TESTDB/#sql2-3b5b-8'

(err no: 152)

What does this message mean. Is my syntax wrong? By the way, I only want to remove the FOREIGN KEY on the CUSTOMERID but don't want any changes for the rest of the database.

SHARE
Answered By 0 points N/A #86855

ERROR 1025 (HY000): Error on rename of ‘./TESTDB/ORDERS’ to ‘./TESTDB/#sql2-3b5b-8’

qa-featured

 

Hi,

This is a foreign key error and the concept to understand here is that before you delete or drop a foreign key column, you must drop the index created on it. To accomplish that, issue the following command:
 
MySQL> show create table orders;
 
It should come up with something:
 
Constraint <el1mu1> column list etc
 
You need to drop this constraint and then drop the foreign key column by its name.
 
MySQL> alter table order drop foreign key el1mu1;
 
And now
 
MySQL> alter table orders drop column customer id;
 
Hope that helps. Cheers!

 

 

Related Questions