Skip to content

PostgreSQL | Show Index Query #71

Open
@c9s

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;

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions