Removes one or more columns from the named row(s).
DELETE [<column_name> [, ...]]
FROM [keyspace.]<column_family>
[USING CONSISTENCY <consistency_level> [AND TIMESTAMP <integer>]]
WHERE <row_specification>;
<row_specification> is:
<primary key name> = <key_value>
<primary key name> IN (<key_value> [,...])
A DELETE statement removes one or more columns from one or more rows in the named column family.
Specifying Columns
After the DELETE keyword, optionally list column names, separated by commas.
DELETE col1, col2, col3 FROM Planeteers USING CONSISTENCY ONE 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');
Specifying the Column Family
The column family name follows the list of column names and the keyword FROM.
Specifying Options
You can specify these options:
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.
Specifying Rows
The WHERE clause specifies which row or rows to delete from the column family.
DELETE col1 FROM SomeColumnFamily WHERE userID = 'some_key_value';
This form provides a list of key names using the IN notation and a parenthetical list of comma-delimited keyname terms.
DELETE col1 FROM SomeColumnFamily WHERE userID IN (key1, key2);
DELETE email, phone
FROM users
USING CONSISTENCY QUORUM AND TIMESTAMP 1318452291034
WHERE user_name = 'jsmith';
DELETE phone FROM users WHERE user_name IN ('jdoe', 'jsmith');
| CQL Commands | CQL Shell Commands |
|---|---|
| ALTER TABLE | ASSUME |
| ALTER KEYSPACE | CAPTURE |
| BATCH | COPY |
| CREATE TABLE | DESCRIBE |
| CREATE INDEX | EXIT |
| CREATE KEYSPACE | SHOW |
| DELETE | SOURCE |
| DROP TABLE | |
| DROP INDEX | |
| DROP KEYSPACE | |
| INSERT | |
| SELECT | |
| TRUNCATE | |
| UPDATE | |
| USE |