sqlstreak

SQL compared

DELETE vs TRUNCATE vs DROP in SQL

Updated · Tested on PostgreSQL 18.6 and SQLite 3.54.1 (results generated , re-checked on every release)

Short answer

DELETE removes rows: all of them, or only those matching WHERE. TRUNCATE empties a whole table quickly (PostgreSQL; SQLite has no TRUNCATE, and DELETE without WHERE does the job). DROP TABLE removes the table itself, columns and all.

Side by side

DELETETRUNCATEDROP TABLE
RemovesRows (all or filtered)Every rowThe table and its rows
WHEREYesNoNo
Table afterwardsStill thereStill there, emptyGone
SQLiteYesNo (use DELETE without WHERE)Yes

The same data, each way

Every query below was run on PostgreSQL and SQLite when this page was built; the tables are what came back.

DELETE with WHERE: some rows

Every run here is rolled back, so the sample data is safe.

DELETE FROM order_items WHERE order_id = 1;
SELECT COUNT(*) AS lines_left FROM order_items;

Result (PostgreSQL and SQLite, identical): 1 row

lines_left
30

Try it: PostgreSQL playground · SQLite playground

TRUNCATE: every row (PostgreSQL)

TRUNCATE order_items;
SELECT COUNT(*) AS lines_left FROM order_items;

PostgreSQL: 1 row

lines_left
0

SQLitenear "TRUNCATE": syntax error

Try it: PostgreSQL playground · SQLite playground

DELETE without WHERE: every row, in both

DELETE FROM order_items;
SELECT COUNT(*) AS lines_left FROM order_items;

Result (PostgreSQL and SQLite, identical): 1 row

lines_left
0

Try it: PostgreSQL playground · SQLite playground

DROP TABLE: the table is gone

DROP TABLE order_items;
SELECT COUNT(*) FROM order_items;

PostgreSQLERROR: relation "order_items" does not exist

SQLiteno such table: order_items

Try it: PostgreSQL playground · SQLite playground

When to use which

DELETE

Removing specific rows, or all rows when you also need triggers to fire or want it to work in SQLite.

TRUNCATE

Emptying a big PostgreSQL table quickly, for example a staging table before a reload.

DROP TABLE

When the table itself should no longer exist.

Common mistakes

  • DELETE FROM t without WHERE when you meant a few rows. Write the WHERE first, and try it as a SELECT.

  • TRUNCATE in SQLite: it's a syntax error there.

  • Truncating or dropping a table other tables point to: PostgreSQL refuses while foreign keys reference it (unless you add CASCADE, which empties those too).

PostgreSQL and SQLite

SQLite has no TRUNCATE (the build shows the syntax error); DELETE FROM t without WHERE empties the table, and SQLite optimises exactly that case. DELETE and DROP TABLE behave the same in both.

Official documentation

Go deeper

Make it stick in five minutes a day

“UPDATE and DELETE” teaches this step by step on a real database, with instant feedback. Part of sqlstreak Pro; the first lessons are free.

Start free