我正在尝试执行此查询:
DROP TABLE categories`
但我有一个错误:
#1217 - Cannot delete or update a parent row: a foreign key constraint fails
我还有一个名为items
的不同表,我也无法删除。这两个表曾经有一个连接(items
表有一个外键category_id
),但我删除了连接。目前,根本没有索引(PK除外)。
如何删除这些表?
答案 0 :(得分:2)
您可以使用information_schema
找出哪个表引用了您的categories
表:
select table_Schema,table_name
from information_schema.key_column_usage
where referenced_table_name = 'categories';