Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PostgreSQL | Show Index Query #71

Open
c9s opened this issue Jan 20, 2015 · 0 comments
Open

PostgreSQL | Show Index Query #71

c9s opened this issue Jan 20, 2015 · 0 comments

Comments

@c9s
Copy link
Owner

c9s commented Jan 20, 2015

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;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant