gpt4 book ai didi

cassandra - 无法更改/更改 cql cassandra 中列的数据类型

转载 作者:行者123 更新时间:2023-12-04 01:37:00 25 4
gpt4 key购买 nike

CREATE TABLE mykespace.newtable (
name text PRIMARY KEY,
marks int,
score float,
value float,
value2 blob
)

cqlsh:mykespace> alter table newtable alter value type int;
InvalidRequest: Error from server: code=2200 [Invalid query] message="Altering of types is not allowed"

cqlsh:mykespace> alter table newtable alter value2 type varint;
InvalidRequest: Error from server: code=2200 [Invalid query] message="Altering of types is not allowed"

无法更改数据类型,甚至 int 到 varint 和 float 到 int

最佳答案

从 Cassandra 3.10 和 3.0.11 开始,更改列数据类型的功能已被 CASSANDRA-12443 删除。 .

...because we no longer store the length for all types anymore, switching from a fixed-width to variable-width type causes issues. commitlog playback breaking startup, queries currently in flight getting back bad results, and special casing required to handle the changes.

这里最好的解决方法是删除现有列,并创建一个具有不同名称的新列(以避免提交日志重放的潜在问题)。比如:

ALTER TABLE mykeyspace.newtable DROP value;
ALTER TABLE mykeyspace.newtable ADD value_int int;

关于cassandra - 无法更改/更改 cql cassandra 中列的数据类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49321164/

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