Skip to content

Delete data ​

DELETE removes rows satisfying its WHERE condition. Without WHERE, it removes every row but keeps the table definition. DROP TABLE removes the table itself.

Changes complete synchronously and use ordinary transaction rules. Foreign-key actions apply when enabled. TTL, partition drops and background deletion queues are not provided.

Example ​

sql
CREATE TABLE tasks(id INTEGER PRIMARY KEY, completed Bool);
INSERT INTO tasks VALUES (1, true), (2, false);
sql
DELETE FROM tasks
WHERE completed
RETURNING id
FORMAT csv;
text
1
sql
SELECT id
FROM tasks
FORMAT csv;
text
2

RETURNING reads deleted values. Use a transaction when the deletion must commit or roll back together with other changes.

See the DELETE reference, DROP and transactions.