title: Retrieving column names from table -Redshift
body: <p>I have a table as below:</p>
  
  <pre><code>create table venue_ident
  
  (venueid bigint identity(0, 1)NOT NULL,
   venuename varchar(100) default 'city',
   venuecity varchar(30),
   venuestate char(2),
   venueseats integer,
   primary key(venueid));
  </code></pre>
  
  <p>Whenever I use the query</p>
  
  <pre><code> select DISTINCT c.column_name,
   a.attencodingtype,
   a.attnotnull,
   a.atttypid::regtype,
   a.attnum
  
  FROM   pg_attribute a , information_schema.columns c ,PG_TABLE_DEF as p
  where    attnum &gt; 0
   AND    NOT attisdropped
   AND c.ordinal_position=a.attnum
   and c.column_name=a.attname
   and c.table_name='venue_ident'
   and a.attnotnull=p.notnull
  
  ORDER by a.attnum;
  </code></pre>
  
  <p>It always outputs 6 columns instead of 5 . It shows primary key column (<code>venue_id</code>) twice with different values for not null condition.
  How do i get just the 5 columns</p>
  
  <pre><code>(venueid, venuename, venuecity, venuestate, venueseats)
  </code></pre>