[英]How to flush data in all tables of keyspace in cassandra?
I am currently writing tests in golang and I want to get rid of all the data of tables after finishing tests.我目前正在 golang 中编写测试,我想在完成测试后摆脱表的所有数据。 I was wondering if it is possible to flush the data of all tables in cassandra.
想知道能不能把cassandra里面所有表的数据都flush掉。
FYI: I am using 3.11 version of Cassandra.仅供参考:我使用的是 Cassandra 的 3.11 版本。
The term "flush" is ambiguous in this case.在这种情况下,术语“同花顺”是不明确的。
In Cassandra, "flush" is an operation where data is "flushed" from memory and written to disk as SSTables.在 Cassandra 中,“刷新”是将数据从 memory 中“刷新”并作为 SSTables 写入磁盘的操作。 Flushing can happen automatically based on certain triggers or can be done manually with the
nodetool flush
command.刷新可以根据某些触发器自动发生,也可以使用
nodetool flush
命令手动完成。
However based on your description, what you want is to "truncate" the contents of tables.但是根据您的描述,您想要的是“截断”表的内容。 You can do this using the following CQL command:
您可以使用以下 CQL 命令执行此操作:
cqlsh> TRUNCATE ks_name.table_name
You will need to iterate over each table in the keyspace.您将需要遍历键空间中的每个表。 For more info, see the CQL
TRUNCATE
command .有关详细信息,请参阅CQL
TRUNCATE
命令。 Cheers!干杯!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.