我在更改 cassandra 表中的列类型时遇到问题。
这是文档的链接,该链接说如果列不是 PRIMARY KEY 的一部分并且没有索引,则可以更改类型。我只是无法让它工作。
cqlsh:test> show VERSION
[cqlsh 3.1.8 | Cassandra 1.2.13 | CQL spec 3.0.0 | Thrift protocol 19.36.2]
CREATE TABLE mytable (
id1 text,
id2 text,
col1 int,
col2 bigint,
col3 text,
PRIMARY KEY (id1, id2)
) WITH CLUSTERING ORDER BY (id2 DESC);
UPDATE mytable SET col1 = 123, col2 = 1234, col3 = '12345' WHERE id1 = 'id1' AND id2 = 'id2';
SELECT * FROM mytable ;
id1 | id2 | col1 | col2 | col3
-----+-----+------+------+-------
id1 | id2 | 123 | 1234 | 12345
当我尝试更改列类型时,出现错误。
ALTER TABLE mytable ALTER col1 TYPE text;
Bad Request: Cannot change col1 from type int to type text: types are incompatible.
ALTER TABLE mytable ALTER col1 TYPE text;
Bad Request: Cannot change col1 from type int to type text: types are incompatible.
ALTER TABLE mytable ALTER col2 TYPE text;
Bad Request: Cannot change col2 from type bigint to type text: types are incompatible.
ALTER TABLE mytable ALTER col3 TYPE bigint;
Bad Request: Cannot change col3 from type text to type bigint: types are incompatible.
ALTER TABLE mytable ALTER col3 TYPE int;
Bad Request: Cannot change col3 from type text to type int: types are incompatible.
我错过了什么或做错了什么?任何帮助表示赞赏。