SQL · Writing data

truncate

Removes every row quickly and resets identity in PostgreSQL. It cannot be easily rolled back selectively.

Syntax
truncate table name

Example

Open in the lab

Notes

TRUNCATE is not available in SQLite; use DELETE FROM without a WHERE clause.

More in this group

delete insert insert from select insert returning merge update update from upsert

Learn this in the course

Reference pages are the quick answer. The course explains the why, shows the full example and ends with a challenge.

Open the course