Skip to content

Instantly share code, notes, and snippets.

@linfongi
Created February 10, 2016 19:36
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 linfongi/ce1d2e80b7570acaa057 to your computer and use it in GitHub Desktop.
Save linfongi/ce1d2e80b7570acaa057 to your computer and use it in GitHub Desktop.
SELECT
t.relname AS table_name,
i.relname AS index_name,
a.attname AS column_name
FROM
pg_class t,
pg_class i,
pg_index ix,
pg_attribute a
WHERE
t.oid = ix.indrelid
AND i.oid = ix.indexrelid
AND a.attrelid = t.oid
AND a.attnum = ANY(ix.indkey)
AND t.relkind = 'r'
AND t.relname like 'folder'
ORDER BY
t.relname,
i.relname;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment