MySQL See all columns and tables that foreign key to a table or column

mysql foreign keyIf you’re trying to understand how an existing database has been setup it can be very useful to see all of the tables/columns that foreign key into some other table/column.

use INFORMATION_SCHEMA;
select TABLE_NAME,COLUMN_NAME,CONSTRAINT_NAME,
REFERENCED_TABLE_NAME,REFERENCED_COLUMN_NAME from KEY_COLUMN_USAGE where
REFERENCED_TABLE_NAME = 'your_table_name'
AND REFERENCED_COLUMN_NAME = 'your_column_name'