如何重命名Cassandra CQL3中的表 [英] How to rename table in Cassandra CQL3

查看:592
本文介绍了如何重命名Cassandra CQL3中的表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试重命名通过CQLSH创建的表。
例如将表AAA重命名为BBB。找不到任何命令这样做。任何想法?

I'm trying to rename table created via CQLSH. E.g. rename table "AAA" to "BBB". Can't find any command to do so. Any ideas?

使用[cqlsh 3.1.6 | Cassandra 1.2.8 | CQL spec 3.0.0 | Thrift协议19.36.0]

Using [cqlsh 3.1.6 | Cassandra 1.2.8 | CQL spec 3.0.0 | Thrift protocol 19.36.0]

推荐答案

我不相信你可以重命名表或键空间,没有CQL3操作,如果我记得正确的话,在旧的Thirft接口中也没有任何东西。

I don't believe you can rename tables or keyspaces, there's no CQL3 operation to do it, and nothing in the old Thirft interfaces either, if I remember correctly.

Cassandra做一个非常难的事情由于其分布式特性,变化不能原子性地进行,因此集群将处于不一致的状态,并且很可能更新将丢失。它类似于创建和删除表,但在这些情况下,如果在创建表之前或删除表之后发布更新,那么更新将会丢失。

One reason why you can't is that it would be an extremely hard thing for Cassandra to do due to its distributed nature, the change can't be done atomically so the cluster would be in an inconsistent state, and most likely updates would be lost. It's similar to creating and dropping tables, but in those cases it's expected that updates will be lost if they're issued before the table is created or after it has been dropped.

我知道要做的事情的唯一方法是创建新表并将所有数据从旧的移动到新的,然后删除旧的表。可能有一种方法可以在不移动数据的情况下执行此操作,但可能需要停止集群并更改属于表的所有目录和文件的名称,并更改 system.schema_columnfamilies 表(但我不知道你可以这样做)。

The only way that I know of to do what you ask is to create the new table and move all the data from the old to the new, then drop the old table. There might be a way to do it without moving the data, but it would probably require you to stop the cluster and change the name of all directories and files belonging to the table, and also change the metadata in the system.schema_columnfamilies table (but I'm not sure you can even do that).

这篇关于如何重命名Cassandra CQL3中的表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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