Skip to content

Instantly share code, notes, and snippets.

@dexalex84
Created November 19, 2016 15:03
Show Gist options
  • Save dexalex84/4dff2796c7a520c2fee4a3f2938e84b4 to your computer and use it in GitHub Desktop.
Save dexalex84/4dff2796c7a520c2fee4a3f2938e84b4 to your computer and use it in GitHub Desktop.
PostgreSQL Show Indexes and IsUnique Flag in tables
select
n.nspname TableSchema,
c.relname as TableName,
a.relname as IndexName,
b.indisunique IsUnique
from
pg_class a
inner join
pg_index b
on
a.oid = b.indexrelid
inner join
pg_class c
on
b.indrelid = c.oid
JOIN
pg_catalog.pg_namespace n ON
n.oid = a.relnamespace
where
a.relname not like 'pg_%'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment