Cassandra: change type from UUID to TIMEUUID

岁酱吖の 提交于 2019-12-13 01:05:58

问题


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;

Error:

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?


回答1:


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.



来源:https://stackoverflow.com/questions/21534139/cassandra-change-type-from-uuid-to-timeuuid

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!