Removes entire rows or one or more columns from one or more rows.
DELETE column_name, ... | collection_colname [ term ] FROM keyspace_name.table_name USING TIMESTAMP integer WHERE row_specification
term is:
[ list_index_position | [ list_value ]
row_specification is:
primary_key_name = key_value primary_key_name IN ( key_value, key_value, ...)
A DELETE statement removes one or more columns from one or more rows in a table, or it removes the entire row if no columns are specified. Cassandra applies seletions within the same partition key atomically and in isolation.
After the DELETE keyword, optionally list column names, separated by commas.
DELETE col1, col2, col3 FROM Planeteers WHERE userID = 'Captain';
When no column names are specified, the entire row(s) specified in the WHERE clause are deleted.
DELETE FROM MastersOfTheUniverse WHERE mastersID IN ('Man-At-Arms', 'Teela');
When a column is deleted, it is not removed from disk immediately. The deleted column is marked with a tombstone and then removed after the configured grace period has expired. The optional timestamp defines the new tombstone record. See About deletes for more information about how Cassandra handles deleted columns and rows.
The table name follows the list of column names and the keyword FROM.
You can identify the column for deletion using a timestamp.
DELETE email, phone FROM users USING TIMESTAMP 1318452291034 WHERE user_name = 'jsmith';
The TIMESTAMP input is an integer representing microseconds.
Specifying Rows
The WHERE clause specifies which row or rows to delete from the table.
DELETE col1 FROM SomeTable WHERE userID = 'some_key_value';
This form provides a list of key names using the IN notation and a parenthetical list of comma-delimited key names.
DELETE col1 FROM SomeTable WHERE userID IN (key1, key2);
DELETE phone FROM users WHERE user_name IN ('jdoe', 'jsmith');
To delete an element from the map, use the DELETE command and enclose the timestamp of the element in square brackets:
DELETE todo ['2012-9-24'] FROM users WHERE user_id = 'frodo';
To remove an element from a list, use the DELETE command and the list index position in square brackets:
DELETE top_places[3] FROM users WHERE user_id = 'frodo';
To remove all elements from a set, you can use the DELETE statement:
DELETE emails FROM users WHERE user_id = 'frodo';