Delete Rows
db_delete_manyDeletes rows from a PostgreSQL table using a JSON filter. Supports dry-run to preview the deletion scope and requires explicit confirmation for full-table deletes.
Instructions
Deletes all rows matching the given filter. This is a destructive operation — deleted data cannot be recovered unless a backup exists. When the filter is empty ('{}'), ALL rows in the table would be deleted — this requires confirmAll=true as a safety gate. A warning is issued when more than 10 rows are affected. Use dry_run=true to preview the deletion scope before committing.
When to use:
"Delete all logs older than 2025"
"Remove user with email test@test.com"
"Purge expired sessions"
Parameter guidance:
table: the target table name (required)
where: JSON filter selecting rows to delete (required). Example: {"expired": true} Use '{}' with confirmAll=true to delete ALL rows (dangerous!).
dry_run: set to true to preview without deleting (default: false). STRONGLY recommended — always dry-run first to see how many rows would be affected.
confirmAll: REQUIRED when where='{}' to confirm deleting all rows
Behavioral notes:
A warning is emitted when more than 10 rows would be affected.
Empty filter with confirmAll=false returns an error requiring explicit confirmation.
The delete runs in a transaction — all rows are deleted atomically.
Returns the count of deleted rows.
ALWAYS use dry_run=true first to verify the scope before committing.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| table | Yes | Name of the table to query | |
| where | Yes | JSON filter selecting rows to delete | |
| dryRun | No | If true, simulates without deleting | |
| database | No | Name of the database to query (from pgautopilot.json). Omit to use the current default database. | |
| confirmAll | No | Required to delete all rows when where is '{}' |