从表-Redshift中检索列名

时间:2018-05-07 08:14:33

标签: sql amazon-redshift

我有一张表格如下:

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));

每当我使用查询

 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 > 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;

它总是输出6列而不是5列。它显示主键列(venue_id)两次,其中非空条件的值不同。 我如何得到5列

(venueid, venuename, venuecity, venuestate, venueseats)

0 个答案:

没有答案