How do I get a list of all foreign key constraints pointing TO (and FROM) a particular table and/or a particular column from a MySQL database built with MyISAM? This is the same as this InnoDB question, but MyISAM specific for MySQL.
Consider the canonical airlines dataset. When I run the following two queries based on the linked question's accepted answer (TO) and Node's answer (FROM), my results are empty set.
Show all the foreign keys pointing TO 'mytable':
SELECT
TABLE_NAME, COLUMN_NAME, CONSTRAINT_NAME, REFERENCED_TABLE_SCHEMA, REFERENCED_TABLE_NAME, REFERENCED_COLUMN_NAME
FROM
INFORMATION_SCHEMA.KEY_COLUMN_USAGE
WHERE
REFERENCED_TABLE_SCHEMA = 'airlines' AND -- <database>
REFERENCED_TABLE_NAME = 'airports'; -- <table> flights, carriers, planes
Show all the foreign keys pointing FROM 'mytable':
SELECT * FROM information_schema.TABLE_CONSTRAINTS
WHERE information_schema.TABLE_CONSTRAINTS.CONSTRAINT_TYPE = 'FOREIGN KEY'
AND information_schema.TABLE_CONSTRAINTS.TABLE_SCHEMA = 'airlines'
AND information_schema.TABLE_CONSTRAINTS.TABLE_NAME = 'carriers';
Am I misidentifying the REFERENCED_TABLE_SCHEMA? Does this query only work in InnoDB?