#1025 - Error on rename (errno: 150) in mysql

后端 未结 2 1232
醉话见心
醉话见心 2021-01-12 09:17

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
         


        
2条回答
  •  [愿得一人]
    2021-01-12 10:09

    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;
      

提交回复
热议问题