Deleting all rows from Cassandra cql table

Aarish Ramesh picture Aarish Ramesh · Aug 25, 2014 · Viewed 75.2k times · Source

Is there a command to all the rows present in a cql table in cassandra like the one in sql?

delete from TABLE

Going by the documentation, I don't find any way to perform delete operation without a where condition.

DELETE col1 FROM SomeTable WHERE userID = 'some_key_value'; 

Answer

Aaron picture Aaron · Aug 25, 2014

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.