Primary keys in Postgresql
<p>I am using postgres and I  found this query to retrieve primary key of a table</p>

<pre><code>SELECT a.attname, format_type(a.atttypid, a.atttypmod) AS data_type
FROM   pg_index i
JOIN   pg_attribute a ON a.attrelid = i.indrelid
                     AND a.attnum = ANY(i.indkey)
WHERE  i.indrelid = 'tablename'::regclass
AND    i.indisprimary;
</code></pre>

<p>I want to retrieve all primary keys and indexes in a databese. How to do this?
<br>
Thank you</p>