title: How to query for a table's primary keys in Redshift
body: <p>I tried to use the code suggested on the Postgresql wiki (<a href="https://wiki.postgresql.org/wiki/Retrieve_primary_key_columns" rel="noreferrer">https://wiki.postgresql.org/wiki/Retrieve_primary_key_columns</a>): </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>Unfortunately, it doesn't seem to work in Redshift.  And I get this error:</p>
  
  <pre><code>ERROR:  op ANY/ALL (array) requires array on right side
  </code></pre>
  
  <p>Am I doing something wrong or is this yet another redshift anomaly?</p>
  
  <p>Any help would be greatly appreciated.</p>