Remove rows from a table.

Removes rows from a table, optionally filtered by WHERE. Without WHERE, all rows are deleted (triggers fire per row in some databases). Use OUTPUT/RETURNING to capture deleted data before it is gone.

Compatibility

Show:
Database System Support Status Since Version Notes
MySQL ✓ Supported all Standard
PostgreSQL ✓ Supported all Standard
SQL Server ✓ Supported all Standard + OUTPUT
Oracle ✓ Supported all Standard + RETURNING
SQLite ✓ Supported all Standard

Details

Basic DML for removing rows.

Standard Syntax

DELETE FROM table_name WHERE condition;

Version Support

MySQL: Since all PostgreSQL: Since all SQL Server: Since all Oracle: Since all SQLite: Since all

Per-Database Syntax & Notes

MySQL

Standard

DELETE FROM tbl WHERE …;

PostgreSQL

Standard

DELETE FROM tbl WHERE … RETURNING *;

SQL Server

Standard + OUTPUT

DELETE FROM tbl OUTPUT deleted.* WHERE …;

Oracle

Standard + RETURNING

DELETE FROM tbl WHERE … RETURNING * INTO …;

SQLite

Standard

DELETE FROM tbl WHERE …;