This article is half-done without your Comment! *** Please share your thoughts via Comment ***
In this post, I am sharing a script to find the list of Foreign Keys with the source and destination table information of a MySQL Database.
Using below script you can easily find all foreign keys of a MySQL Database and its very useful for Database Architect for finding different references of foreign keys.
I am finding all Foreign Key references using INFORMATION_SCHEMA.KEY_COLUMN_USAGE.
Below is a script:
1 2 3 4 5 6 7 |
SELECT referenced_table_name AS ParentTable ,table_name AS ChildTable ,constraint_name AS ConstraintName FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE WHERE referenced_table_name IS NOT NULL ORDER BY referenced_table_name; |
PostgreSQL: Script to find Source and Destination of All Foreign Key Constraint