Delete a value or entire row
Use a `DELETE` statement to replace a value in a column with null or remove an entire row of data.
Deleted values are typically replaced by tombstones, and then removed completely by the first compaction following deletion.
INSERT
/UPDATE
statements that are upserts are technically a deletions because the previously stored data is deleted and replaced with the updated data.
Use a DELETE statement
-
Delete one value from the
lastname
column in thecyclist_name
table. The row to delete from is identified by the primary key column,id
.DELETE lastname FROM cycling.cyclist_name WHERE id = c7fceba0-c141-4207-9494-a29f9809de6f;
Only the value in
lastname
in the specified row is deleted. -
Delete an entire row from the
calendar
table. The row to delete is identified by the primary key column,race_id
.DELETE FROM cycling.calendar WHERE race_id = 201;
No column is specified between
DELETE
andFROM
, so all values in the specified row are deleted.
Use TTL to expire data
You can also define a Time-To-Live (TTL) value for an individual column or an entire table. This property causes the database to delete the data automatically after a certain amount of time has elapsed. For details, see Expiring data with time-to-live.