Skip to content

PostgreSQL | Show Index Query #71

Description

@c9s
SELECT t.relname as table_name, i.relname as index_name, a.attname as column_name
FROM pg_class t 
LEFT JOIN pg_index ix ON (t.oid = ix.indrelid) 
LEFT JOIN pg_class i ON (i.oid = ix.indexrelid) 
LEFT JOIN pg_attribute a ON (a.attrelid = t.oid ) 
WHERE 
    a.attnum = ANY(ix.indkey) AND t.relkind = 'r'
ORDER BY table_name, index_name;

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions