Cassandra:将类型从UUID更改为TIMEUUID [英] Cassandra: change type from UUID to TIMEUUID

查看:146
本文介绍了Cassandra:将类型从UUID更改为TIMEUUID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将列的类型从UUID更改为TIMEUUID,但是我无法这样做。

I'm trying to change the type of a column from UUID to TIMEUUID, but I'm unable to do so.

ALTER TABLE Person ALTER KEY TYPE timeuuid;

错误:


错误请求:无法将密钥从uuid类型更改为timeuuid类型:类型不兼容。

Bad Request: Cannot change key from type uuid to type timeuuid: types are incompatible.

关于如何实现此目的的任何想法不会丢失列族中的数据?

Any idea on how to achieve this without losing the data from the column family?

推荐答案

这是不允许的。这是因为TimeUUID与常规UUID具有不同的排序模式,因此Cassandra不允许这样做。如果您不希望按时间对列进行排序,则可以在应用程序中生成和使用TimeUUID,而无需更改Cassandra中的列类型,但是如果将这些列与现有列混合使用,则排序可能会混乱。如果您绝对需要这样做,则唯一的选择是迁移现有数据,并将其列更改为UUID的新列族。

It is not allowed. This is because TimeUUIDs have a different sorting pattern than regular UUIDs so Cassandra does not allow this. If you don't care about Columns being sorted by time, you can generate and use TimeUUID in your application without changing the column type in Cassandra, but the sorting may be out of order if mixed with those existing columns. If you absolutely need to do this, your only option would be to migrate your existing data and change its columns to UUID to a new column family.

这篇关于Cassandra:将类型从UUID更改为TIMEUUID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆