{"id":5471,"date":"2016-10-24T09:02:58","date_gmt":"2016-10-24T09:02:58","guid":{"rendered":"http:\/\/www.withdata.com\/blog\/?p=5471"},"modified":"2017-04-20T11:01:37","modified_gmt":"2017-04-20T11:01:37","slug":"how-to-get-index-column-names-of-a-table-from-postgresql","status":"publish","type":"post","link":"https:\/\/www.withdata.com\/blog\/postgresql\/how-to-get-index-column-names-of-a-table-from-postgresql.html","title":{"rendered":"How to get index column names of a table from PostgreSQL"},"content":{"rendered":"<p><code>select i.relname as index_name, a.attname as column_name<br \/>\nfrom pg_class t, pg_class i, pg_index ix, pg_attribute a, pg_namespace n<br \/>\nwhere t.oid = ix.indrelid and i.oid = ix.indexrelid and a.attrelid = t.oid<br \/>\nand a.attnum = ANY(ix.indkey) and n.oid=t.relnamespace and t.relkind = 'r'<br \/>\nand t.relname='my_table_name'<br \/>\nand n.nspname='my_schema_name'<\/code><\/p>\n<p>See also:<\/p>\n<p><a href=\"http:\/\/www.withdata.com\/blog\/db2\/how-to-get-index-column-names-of-a-table-from-db2.html\">How to get index column names of a table from DB2<\/a><\/p>\n<p><a href=\"http:\/\/www.withdata.com\/blog\/sql-server\/how-to-get-index-column-names-of-a-table-from-sql-server.html\">How to get index column names of a table from SQL Server<\/a><\/p>\n<p><a href=\"http:\/\/www.withdata.com\/blog\/mysql\/how-to-get-index-column-names-of-a-table-from-mysql.html\">How to get index column names of a table from MySQL<\/a><\/p>\n<p><a href=\"http:\/\/www.withdata.com\/blog\/sqlite\/how-to-get-index-column-names-of-a-table-from-sqlite.html\">How to get index column names of a table from SQLite<\/a><\/p>\n<p><a href=\"http:\/\/www.withdata.com\/blog\/oracle\/how-to-get-index-column-names-of-a-table-from-oracle.html\">How to get index column names of a table from Oracle<\/a><\/p>\n<p>Some PostgreSQL tools you can try: <a href=\"https:\/\/www.withdata.com\/postgresql\/\"> https:\/\/www.withdata.com\/postgresql\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>select i.relname as index_name, a.attname as column_name from pg_class t, pg_class i, pg_index ix, pg_attribute a, pg_namespace n where t.oid = ix.indrelid and i.oid = ix.indexrelid and a.attrelid = t.oid and a.attnum = ANY(ix.indkey) and n.oid=t.relnamespace and t.relkind = &#8216;r&#8217; and t.relname=&#8217;my_table_name&#8217; and n.nspname=&#8217;my_schema_name&#8217; See also: How to get index column names of a table [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[430],"tags":[1720,1370],"class_list":["post-5471","post","type-post","status-publish","format-standard","hentry","category-postgresql","tag-get-index-columns","tag-postgresql"],"_links":{"self":[{"href":"https:\/\/www.withdata.com\/blog\/wp-json\/wp\/v2\/posts\/5471","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.withdata.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.withdata.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.withdata.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.withdata.com\/blog\/wp-json\/wp\/v2\/comments?post=5471"}],"version-history":[{"count":3,"href":"https:\/\/www.withdata.com\/blog\/wp-json\/wp\/v2\/posts\/5471\/revisions"}],"predecessor-version":[{"id":6443,"href":"https:\/\/www.withdata.com\/blog\/wp-json\/wp\/v2\/posts\/5471\/revisions\/6443"}],"wp:attachment":[{"href":"https:\/\/www.withdata.com\/blog\/wp-json\/wp\/v2\/media?parent=5471"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.withdata.com\/blog\/wp-json\/wp\/v2\/categories?post=5471"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.withdata.com\/blog\/wp-json\/wp\/v2\/tags?post=5471"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}