删除 Cassandra cql 表中的所有行

Cassandra 中的 cql 表中的所有行是否都有一个命令,就像 sql 中的那个一样?

delete from TABLE

根据文档,我找不到在没有 where 条件的情况下执行 delete 操作的任何方法。

DELETE col1 FROM SomeTable WHERE userID = 'some_key_value';
95616 次浏览

To remove all rows from a CQL Table, you can use the TRUNCATE command:

TRUNCATE keyspace_name.table_name;

Or if you are already using the keyspace that contains your target table:

TRUNCATE table_name;

Important to note, but by default Cassandra creates a snapshot of the table just prior to TRUNCATE. Be sure to clean up old snapshots, or set auto_snapshot: false in your cassandra.yaml.