Last active
July 17, 2019 22:08
-
-
Save tym-xqo/3d75cc2f0e169b95566c413511895057 to your computer and use it in GitHub Desktop.
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 c.table_schema | |
, c.constraint_name | |
, c.table_name | |
, k.column_name | |
, u.table_schema as foreign_table_schema | |
, u.table_name as foreign_table_name | |
, u.column_name as foreign_column_name | |
from information_schema.table_constraints as c | |
join information_schema.key_column_usage as k | |
on c.constraint_name = k.constraint_name | |
and c.table_schema = k.table_schema | |
join information_schema.constraint_column_usage as u | |
on u.constraint_name = c.constraint_name | |
and u.table_schema = c.table_schema | |
where c.constraint_type = 'FOREIGN KEY' | |
and c.table_name='some_table'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment