gpt4 book ai didi

Cassandra:创建表时不能使用 'NOT NULL' 约束

转载 作者:行者123 更新时间:2023-12-04 23:39:55 25 4
gpt4 key购买 nike

我在这里看到许多使用 NOT NULL 约束创建表的示例。具有讽刺意味的是,我似乎不能做同样的事情。

这是我使用的 cql 命令:

CREATE TABLE activities_dev (activity_id  uuid ,actor_id bigint NOT NULL, actor_appid bigint NOT NULL, item_id text NOT NULL, verb text NOT NULL,viewer_id bigint NOT NULL,viewer_appid bigint NOT NULL, ts timestamp, PRIMARY KEY(activity_id,actor_id,actor_appid,item_id,verb));

但这是我得到的错误:
SyntaxException: line 1:62 mismatched input 'NOT' expecting ')' (...activities_dev(activity_id uuid, actor_id integer [NOT] NULL...)

我究竟做错了什么 ?

最佳答案

在 Cassandra 中,不支持 NOT NULL 关键字。

对于主键列,cassandra 会自动处理。如果您尝试将 null 插入任何主键值,cassandra 将抛出异常
Invalid null value in condition for column

关于Cassandra:创建表时不能使用 'NOT NULL' 约束,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41100756/

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