MySQL: How do I find out which tables reference a specific table?

前端 未结 7 1980
挽巷
挽巷 2021-01-31 08:21

I want to drop a table but it is referenced by one or more other tables. How can I find out which tables are referencing this table without having to look at each of the tables

7条回答
  •  一整个雨季
    2021-01-31 08:44

    select table_name
    from information_schema.KEY_COLUMN_USAGE
    where table_schema = 'my_database'
    and referenced_table_name = 'my_table_here';
    

    This works.

提交回复
热议问题