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

查看:21
本文介绍了如何在 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 |卡桑德拉 1.2.8 |CQL 规范 3.0.0 |节俭协议 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天全站免登陆