将主键添加到Create [params]作为查询语句

时间:2015-06-23 19:06:58

标签: database amazon-redshift

如何将主键添加到create as query语句?我尝试了以下但它抛出了一个错误。当我取出主键部分时,此查询可以正常工作:

  --redshift statement
  DROP TABLE IF EXISTS egtable;
  CREATE TEMPORARY TABLE egtable
  primary key (id),sortkey (b)
  as
  select 1 as id, 2 as b;

1 个答案:

答案 0 :(得分:0)

你会想要这样的东西:

DROP TABLE IF EXISTS egtable;
CREATE TEMPORARY TABLE egtable
(
  id int,
  b int,
  primary key (id)  
)
distkey(b);

insert into egtable select 1, 2