gpt4 book ai didi

snowflake-cloud-data-platform - 如何限制重复记录插入雪花中的表

转载 作者:行者123 更新时间:2023-12-03 14:38:31 25 4
gpt4 key购买 nike

我已经在雪花中创建了具有主键的下表,并且每当我尝试向该表中插入数据时,它也允许重复记录。
如何限制重复的ID?

create table tab11(id int primary key not null,grade varchar(10));

insert into tab11 values(1,'A');
insert into tab11 values(1,'B');

select * from tab11;

输出:插入重复的记录。
ID  GRADE
1 A
1 B

最佳答案

Snowflake允许您将列标识为主键,但不会对它们强制执行唯一性。从documentation here:

Snowflake supports defining and maintaining constraints, but does not enforce them, except for NOT NULL constraints, which are always enforced.


Snowflake中的主键仅用于提供信息。我不是来自Snowflake,但我想像一下,在Primary Keys中强制唯一性与Snowflake在幕后存储数据的方式实际上并不一致,并且可能会影响插入速度。

关于snowflake-cloud-data-platform - 如何限制重复记录插入雪花中的表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59873201/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com