Нечто вроде такого запроса:

SELECT table_name, column_name, referenced_table_name, referenced_column_name, constraint_name FROM `information_schema`.`KEY_COLUMN_USAGE`
where table_schema='schematest' and (referenced_table_name = 'sotm_product' or table_name = 'sotm_product') and referenced_table_name is not null;

Выполняются такие запросы очень медленно:


mysql> explain SELECT table_name, column_name, referenced_table_name, referenced_column_name, constraint_name FROM `information_schema`.`KEY_COLUMN_USAGE`
where table_schema='schematest' and (referenced_table_name = 'sotm_product' or table_name = 'sotm_product') and referenced_table_name is not null;
+----+-------------+------------------+------+---------------+--------------+---------+------+------+--------------------------------------------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+------------------+------+---------------+--------------+---------+------+------+--------------------------------------------------+
| 1 | SIMPLE | KEY_COLUMN_USAGE | ALL | NULL | TABLE_SCHEMA | NULL | NULL | NULL | Using where; Open_full_table; Scanned 1 database |
+----+-------------+------------------+------+---------------+--------------+---------+------+------+--------------------------------------------------+
1 row in set (0.04 sec)