Cassandra 选择性复制 [英] Cassandra selective copy
问题描述
我想将列族中的选定行复制到 .csv 文件.copy 命令仅可用于将列或整个表转储到文件中,而无需 where 子句.有没有办法在复制命令中使用 where 子句?
I want to copy selected rows from a columnfamily to a .csv file. The copy command is available just to dump a column or entire table to a file without where clause. Is there a way to use where clause in copy command?
我想到的另一种方式是,
Another way I thought of was,
做插入到table2()值(select * from table1 where
);"然后将 table2 转储到 .csv ,这也是不可能的.
Do "Insert into table2 () values ( select * from table1 where <where_clause>
);" and then dump the table2 to .csv , which is also not possible.
任何帮助将不胜感激.
推荐答案
copy 中没有办法制作 where 子句,但是可以用这个方法:
There are no way to make a where clause in copy, but you can use this method :
echo "select c1,c2.... FROM keySpace.Table where ;"|bin/cqlsh > output.csv
echo "select c1,c2.... FROM keySpace.Table where ;" | bin/cqlsh > output.csv
它允许您将结果保存在 output.csv 文件中.
It allows you to save your result in the output.csv file.
这篇关于Cassandra 选择性复制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!