This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| SELECT DISTINCT t.table_name, rc.referenced_table_name | |
| FROM information_schema.tables t | |
| JOIN information_schema.table_constraints tc USING (table_schema, table_name) | |
| LEFT JOIN information_schema.referential_constraints rc ON tc.table_schema = rc.constraint_schema AND tc.table_name = rc.table_name | |
| WHERE t.table_schema='$DB' | |
| /*AND t.table_name IN ('$TABLE1', '$TABLE2')*/ | |
| AND (tc.constraint_type = 'FOREIGN KEY' OR (rc.table_name IS NULL AND rc.constraint_schema IS NULL)) |
NewerOlder