Cassandra alter column type:哪些类型兼容? [英] Cassandra alter column type: which types are compatible?
问题描述
关于一些示例,当列类型不能更改时,有关网络的一些补丁信息。例如,在 DataStax网站有提及:
- 更改聚类列的类型。
- 更改定义了
的列。
例如,此处提到您无法将 uuid
到 timeuuid
。根据我的个人经验,我不能将 text
更改为 timestamp
(我们将日期以ISO8601格式存储为文本,一个不幸的决定在项目时间表的早期)。
但是,我找不到哪些类型可以转换到哪个类型的完整描述,或至少哪些类型不能转换为。有人知道吗?
很好的问题!我不得不承认,我对这个缺乏详尽的文档有点惊讶,以及。您的问题启发了我做一个小调查和博客。 / p>
基本上,这里是Cassandra兼容的CQL类型的完整列表(使用Cassandra 2.2.0)
:- ascii - > blob,text,varchar
- bigint - > blob ,timestamp,varint
- int - > blob,varint
- ,varchar
- timestamp - > bigint,blob,varint
- timeuuid - > blob ,UUID
- varchar - > blob,文字
:
- blob有很多,因为 可以转换成blob。
- cqlsh允许您将varint转换为新的日期类型,但这是一个错误( CASSANDRA-10027 )。不要尝试。
There's some patchy information on the interwebs about some examples when column type can't be changed. For example, on the DataStax site there's a mention:
- Changing the type of a clustering column.
- Changing columns on which an index is defined.
Or, for example, here is mentioned that you can't convert uuid
to timeuuid
. And from my personal experience, I can't change text
to timestamp
(we store dates in ISO8601 format as text, an unfortunate decision early in the project timeline).
However, I can't find a full description of which types can be converted to which, or at least which types can't be converted to which. Does anyone know?
Great question! I have to admit that I was a bit surprised at the lack of thorough documentation on this one, as well. Your question inspired me to do a little investigation and blog about it as well.
Essentially, here is a comprehensive list of Cassandra compatible CQL types (using Cassandra 2.2.0):
- ascii -> blob, text, varchar
- bigint -> blob, timestamp, varint
- int -> blob, varint
- text -> blob, varchar
- timestamp -> bigint, blob, varint
- timeuuid -> blob, UUID
- varchar -> blob, text
Notes:
- blob is in there a lot, because anything can be converted to a blob.
- cqlsh allows you to convert a varint to the new date type, but this is a bug (CASSANDRA-10027). Don't actually try that.
这篇关于Cassandra alter column type:哪些类型兼容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!