I need to update the table, but DROP TABLE gives the following:

#1451 - Cannot delete or update a parent row: a foreign key constraint fails 

And it is not clear which key hinders the removal - no additional information is displayed. What can be wrong?

  • first remove the child records associated with the parent table by restricting the table, or remove the foreign key (foreign key), then the integrity of the database is not guaranteed. - Jean-Claude
  • show create table ... request show create table ... didn't show anything either? - PinkTux
  • @ Jean-Claude, so the point is that I would like to know which tables are related to this one. How can you see them? - Alex Petrov

1 answer 1

Most likely some other one refers to this table. similar to the answer with en SO: https://stackoverflow.com/questions/4004205/mysql-show-constraints-on-tables-command

You can make a request:

 use INFORMATION_SCHEMA; select TABLE_NAME,COLUMN_NAME,CONSTRAINT_NAME, REFERENCED_TABLE_NAME,REFERENCED_COLUMN_NAME from KEY_COLUMN_USAGE where TABLE_SCHEMA = "название базы данных" and REFERENCED_TABLE_NAME = "название таблицы которую хотите удалить" 
  • Thank you for what you need! - Alex Petrov