小编ist*_*ele的帖子

Insert into() (Amazon Redshift) 时不遵守身份列

当我从一个带有身份、主键和排序键的表中选择到另一个带有自己的一组身份、主键和排序键的表时,我最初遇到了这个问题。它没有尊重定义的 (1,1) 身份,而是执行 (1,8)(有时为 3,8)。我想可能是因为原始表已排序?为了弄清楚发生了什么,我做了一个更简单的查询和数据,并在多个红移集群中找到了一个可重现的示例。拿这个测试例子:

drop table if exists test;
create temp table test (id int identity(1,1) not null
                    , value varchar(16)
                    , primary key (id))
                    diststyle all
                    sortkey (id);
insert into test (value) select 'a';
insert into test (value) select 'b';
insert into test (value) select 'c' union select 'd';
insert into test (value) values ('e'), ('f'), ('g');

select * from test;
Run Code Online (Sandbox Code Playgroud)

我得到的输出是:

id  value
1   a
2   b
9   c
10  d
3   e
4   f
5   g …
Run Code Online (Sandbox Code Playgroud)

postgresql identity amazon-redshift

2
推荐指数
1
解决办法
3037
查看次数

标签 统计

amazon-redshift ×1

identity ×1

postgresql ×1