som*_*ngh 3 cql cassandra cqlsh
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"
Run Code Online (Sandbox Code Playgroud)
无法更改数据类型,甚至无法将 int 更改为 varint 和 float 更改为 int
从 Cassandra 3.10 和 3.0.11 开始,更改列数据类型的功能已被CASSANDRA-12443删除。
...因为我们不再存储所有类型的长度,从固定宽度类型切换到可变宽度类型会导致问题。commitlog 播放中断启动,当前正在运行的查询返回错误结果,以及处理更改所需的特殊大小写。
这里最好的解决方法是删除现有列,并创建一个具有不同名称的新列(以避免 commitlog 重放的潜在问题)。就像是:
ALTER TABLE mykeyspace.newtable DROP value;
ALTER TABLE mykeyspace.newtable ADD value_int int;
Run Code Online (Sandbox Code Playgroud)