Skip to content

Instantly share code, notes, and snippets.

@pramsey
Created May 26, 2015 22:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pramsey/9f66327becaa729aabb3 to your computer and use it in GitHub Desktop.
Save pramsey/9f66327becaa729aabb3 to your computer and use it in GitHub Desktop.
Tables and Foreign Keys
select c1.relname as tbl, r.conname as constraint, c2.relname as frn_tbl
from pg_class c1
join pg_constraint r on c1.oid = r.conrelid
join pg_class c2 on c2.oid = r.confrelid
order by frn_tbl;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment