Skip to content

Instantly share code, notes, and snippets.

@jcoleman
Created February 1, 2019 21:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jcoleman/5fac44d798bbce1d5d4f9c0bd57abb21 to your computer and use it in GitHub Desktop.
Save jcoleman/5fac44d798bbce1d5d4f9c0bd57abb21 to your computer and use it in GitHub Desktop.
SELECT
d.objid::regclass AS owning_object,
d.refobjid::regclass AS dependent_object,
a.attname AS dependent_column,
d.deptype -- The meaning of this type is documented at https://www.postgresql.org/docs/current/catalog-pg-depend.html
FROM pg_catalog.pg_depend d
LEFT JOIN pg_catalog.pg_attribute a ON d.refobjid = a.attrelid
AND d.refobjsubid = a.attnum
WHERE refobjid = '<table>'::regclass
AND a.attname = '<column>';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment