cassandra 将数据从一个列族复制到另一个列族 [英] cassandra copy data from one columnfamily to another columnfamily

查看:23
本文介绍了cassandra 将数据从一个列族复制到另一个列族的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 cassandra 的新手.我需要将数据从一个 columnFamily 复制到 cassandra 中相同键空间中的另一个 columnFamily.例如,我们在键空间 K1 中有一个 A1 columnFamily,所以现在我需要在同一个键空间 K1 中创建 columnFamily A2.这里我需要从中复制数据columnFamily A1 到 A2 .A1 和 A2 具有相同的架构.我阅读了在线文档,其中我们可以使用 sstable 加载器将数据从一个 cassandra 集群复制到另一个集群.但在这里我需要将数据从一个 columnFamily 复制到同一键空间内的另一个 columnFamily .

I am newbie to cassandra . I need to copy data from one columnFamily to another columnFamily in same keyspace in cassandra .Say for ex we have a A1 columnFamily in keyspace K1 , so now i need to create columnFamily A2 in the same keyspace K1 .Here i need to copy data from columnFamily A1 to A2 .A1 and A2 have the same schema .I read online docs where in we can use sstable loader to copy data from one cassandra cluster to another . But here i need to copy data from one columnFamily to another columnFamily within same keyspace .

上面的任何想法.或者它是否可以实现,我不确定.

Any ideas on above . Or is it achievable i am not sure of it .

推荐答案

根据 cassandra 版本,您可以使用 copy cql 命令.要使用它,您需要一个 cql 客户端,例如随 cassandra 一起分发的客户端.

Depending on the cassandra version you can use the copy cql command. To use that you need a cql client like the one that is distributted with cassandra.

首先,您必须使用以下命令将列族 A1 复制到 CSV 文件:

First you have to copy the columnfamily A1 to a CSV file using:

COPY K1.A1 (column1, column2,...) TO 'temp.csv';

然后将文件复制到新的列族

And after that copy the file to the new column family

COPY K1.A2 (column1, column2,...) FROM 'temp.csv';

显然您必须将列的名称更改为您的名称.

Obviously you have to change the name of the columns to your names.

更多信息:

http://www.datastax.com/documentation/cassandra/1.2/index.html#cassandra/cql_reference/copy_r.html

这篇关于cassandra 将数据从一个列族复制到另一个列族的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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