Tips to find tables affected by MySQL ON DELETE CASCADE action
Sometimes, it is useful to know which table is affected by the MySQL ON DELETE CASCADE referential action when you delete data from a table. You can query this data from the referential_constraints in the information_schema database as follows:
1 2 3 4 5 6 7 8 9 10 | USE information_schema; SELECT table_name FROM referential_constraints WHERE constraint_schema = 'database_name' AND referenced_table_name = 'parent_table' AND delete_rule = 'CASCADE' |