# DELETE

DELETE removes rows for which the `WHERE` condition is SQL true. Without `WHERE`, it removes every row while retaining the table definition.

The deletion is applied immediately in the current transaction. Foreign-key actions apply when `foreign_keys` is enabled. Use [`DROP TABLE`](https://coordinatordb.com/docs/reference/statements/drop) to remove the table itself.

## Syntax

```text
DELETE FROM table
[WHERE condition]
[RETURNING expression, ...]
```

`RETURNING` reads the deleted row's values. It does not return the remaining rows.

## Examples

### Removing completed work

```sql
CREATE TABLE queue(id INTEGER PRIMARY KEY, done Bool);
INSERT INTO queue VALUES (1, true), (2, false), (3, true);
```

```sql
DELETE FROM queue
WHERE done
RETURNING id
FORMAT csv;
```

```text
1
3
```

```sql
SELECT id, done
FROM queue
ORDER BY id
FORMAT csv;
```

```text
2,false
```

### Clearing a table

```sql
DELETE FROM queue;
```

```sql
SELECT count(*)
FROM queue
FORMAT csv;
```

```text
0
```

Use [transactions](https://coordinatordb.com/docs/concepts/features/operations/insert/transactions) when a deletion must be committed or rolled back with other changes.
