8

I am trying to drop a foreign key(id) in one table(misc) which is the primary key(id) in table(main). db name(xxx)

alter table misc drop FOREIGN KEY id

I am getting this error

#1025 - Error on rename of '.\interview#sql-edc_27' to '.\interview\misc' (errno: 150)

juergen d
  • 201,996
  • 37
  • 293
  • 362
black
  • 729
  • 5
  • 13
  • 28
  • possible duplicate of [#1025 - Error on rename of './database/#sql-2e0f\_1254ba7' to './database/table' (errno: 150)](http://stackoverflow.com/questions/4080611/1025-error-on-rename-of-database-sql-2e0f-1254ba7-to-database-table) – Kermit Oct 29 '13 at 20:50
  • I have some trouble. This topic help me: https://stackoverflow.com/questions/4080611/1025-error-on-rename-of-database-sql-2e0f-1254ba7-to-database-table – Andrey Batalov Apr 02 '19 at 14:24

2 Answers2

14
SHOW CREATE TABLE misc ;

You can't drop the foreign key using the column name,run the above query to find out the correct name,something like misc_ibfk_1

Heh,IT IS this name:

alter table misc drop FOREIGN KEY  misc_ibfk_1
Mihai
  • 26,325
  • 7
  • 66
  • 81
2

In my case, was necessary to make a 3-step process (my table is named "articulos", and the hard-to-remove index is "FK_Departamento_ID")

  1. For knowing the name of table, I executed:

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

    ALTER TABLE articulos DROP FOREIGN KEY FK_Departamento_ID;
    
  3. The following statement finally wiped out the index

    DROP INDEX FK_Departamento_ID ON articulos;
    
ZooMMX
  • 838
  • 9
  • 14