Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Deleting all rows from Cassandra cql table [duplicate]

Tags:

cassandra

cql

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';  
like image 243
Aarish Ramesh Avatar asked Aug 25 '14 09:08

Aarish Ramesh


People also ask

How do I delete all rows in Cassandra?

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

How do I delete multiple rows in Cassandra?

To delete more than one row, use the keyword IN and supply a list of values in parentheses, separated by commas: DELETE FROM cycling. cyclist_name WHERE firstname IN ('Alex', 'Marianne'); CQL supports an empty list of values in the IN clause, useful in Java Driver applications.


1 Answers

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.

like image 108
Aaron Avatar answered Dec 06 '22 19:12

Aaron