# 1025 - Error renaming (errno: 150) in mysql

I am trying to delete a foreign key (id) in the same table (different), which is the primary key (id) in the table (main). db name (xxx)

alter table misc drop FOREIGN KEY id 

I get this error

# 1025 - Error renaming '. \ Interview # sql-edc_27' to '. \ Interview \ misc' (errno: 150)

+7
mysql
source share
2 answers
 SHOW CREATE TABLE misc ; 

You cannot delete the foreign key using the column name, run the above query to find out the correct name, for example misc_ibfk_1

Heh, this is the name:

 alter table misc drop FOREIGN KEY misc_ibfk_1 
+13
source share

In my case, it was necessary to do a three-step process (my table is called "articulos", and the index with a hard delete is "FK_Departamento_ID")

  • To find out the name of the table, I did:

     SHOW INDEX FROM articulos; 
  • This statement resolved the problem (# 1025, errno: 150), but the index remained in the table

     ALTER TABLE articulos DROP FOREIGN KEY FK_Departamento_ID; 
  • The following statement permanently destroyed the index

     DROP INDEX FK_Departamento_ID ON articulos; 
+1
source share

All Articles