How to Delete Rows in PostgreSQL

Last updated July 24, 2026 · By the SaturnSQL team

Use DELETE FROM ... WHERE, with USING to join another table. RETURNING lists the deleted rows. Wrap risky deletes in a transaction so you can ROLLBACK after inspecting the result.

DDL and DML are both transactional in Postgres, so wrapping a delete in BEGIN gives you a real undo. RETURNING prints what went, you inspect it, then COMMIT or ROLLBACK. An open transaction holds locks, so decide quickly rather than walking away mid-statement.

BEGIN;
DELETE FROM orders WHERE status = 'cancelled' RETURNING id;
-- looks right?
COMMIT; -- or ROLLBACK;

Delete with a join

USING is the Postgres spelling of a delete with a join, and as with UPDATE ... FROM the join condition goes in WHERE. Omitting it deletes the entire table. Turn it into a SELECT first: swap DELETE FROM orders o for SELECT o.* FROM orders o and run the identical USING and WHERE clauses.

DELETE FROM orders o
USING customers c
WHERE c.id = o.customer_id
  AND c.is_test_account;

Run this in SaturnSQL

SaturnSQL is a browser-based SQL editor for teams: shared query library, schema-aware autocomplete, and scheduled exports to Google Sheets and Slack.

Try it free

Related PostgreSQL guides