postgresql index id code example
Example: postgresql index id
postgres@db # SELECT a.attname
FROM pg_class t
JOIN pg_index ix ON t.oid = ix.indrelid
JOIN pg_class i ON i.oid = ix.indexrelid
JOIN pg_attribute a ON a.attrelid = t.oid
WHERE
a.attnum = ANY(ix.indkey) AND
t.relkind = 'r' AND
t.relname ='test' -- table name
ORDER BY
t.relname,
i.relname;
attname
---------
column1
column2
id
(3 rows)