How to Truncate a Table in PostgreSQL

Last updated July 24, 2026 · By the SaturnSQL team

TRUNCATE removes all rows instantly and, unlike MySQL, is transactional in Postgres: you can ROLLBACK it. Use RESTART IDENTITY to reset sequences and CASCADE for tables referenced by foreign keys.

TRUNCATE deallocates whole pages rather than deleting row by row, so it is effectively instant and, unlike DELETE, leaves no dead tuples for VACUUM to clean up. Because it is transactional here you can BEGIN, truncate, check something, and ROLLBACK. It does take an ACCESS EXCLUSIVE lock, so it waits for current readers to finish.

TRUNCATE TABLE session_logs;

Reset sequences and cascade

RESTART IDENTITY resets owned sequences so IDs start from 1 again; without it, the next insert continues from wherever the counter had reached. TRUNCATE refuses to run on a table referenced by a foreign key unless you add CASCADE, which then truncates the referencing tables too. That cascade is easy to underestimate, so check pg_constraint first.

TRUNCATE TABLE orders RESTART IDENTITY CASCADE;

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