Last active
December 27, 2018 16:42
-
-
Save MatthiasKunnen/5e0b433b77c24e97cda2e89cbfb21b7f to your computer and use it in GitHub Desktop.
Postgres
This file contains 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 | |
t.relname as table_name, | |
array_to_string(array_agg(a.attname), ', ') as column_names, | |
i.relname as index_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 not like 'pg%' | |
group by | |
t.relname, | |
i.relname | |
order by | |
t.relname, | |
i.relname; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment