如何更新卡桑德拉的元组?

发布于 2025-01-18 06:18:37 字数 59 浏览 2 评论 0原文

Google 上没有关于如何更新元组的文献教程。 有人可以解释如何在 Cassandra 中更新元组吗?

There are literary no tutorials on how to update tuples on Google.
Can someone explain how tuples can be updated in Cassandra?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

行至春深 2025-01-25 06:18:37

CQL 元组数据类型是隐式“冷冻”的,而无需CQL 冷冻关键字,因此您无法更新tuple column> column -column> column -code> - 您需要更新整列。

为了说明,这是我的示例CQL表:

CREATE TABLE sensors (
    id text PRIMARY KEY,
    location tuple<decimal, decimal>,
    temperature decimal,
    weight int
)

以下是一个示例,我在其中插入一个带有其位置的传感器:

INSERT INTO sensors (id, location)
    VALUES ('abc123', (50.4501, 30.5234));

以下是一个示例,我更新传感器的位置:

UPDATE sensors
    SET location = (47.0971, 37.5434)
    WHERE id = 'abc123';

有关详细信息,请参见 cql tuple type 。干杯!

The CQL tuple data type is implicitly "frozen" without needing the CQL frozen keyword so you can't update individual elements of a tuple column -- you need to update the whole column.

To illustrate, here's my example CQL table:

CREATE TABLE sensors (
    id text PRIMARY KEY,
    location tuple<decimal, decimal>,
    temperature decimal,
    weight int
)

Here's an example where I insert a sensor with its location:

INSERT INTO sensors (id, location)
    VALUES ('abc123', (50.4501, 30.5234));

Here's an example where I update the location of a sensor:

UPDATE sensors
    SET location = (47.0971, 37.5434)
    WHERE id = 'abc123';

For details, see CQL tuple type. Cheers!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文