← all rules

truncate

warning

TRUNCATE

Why it's unsafe

TRUNCATE takes an ACCESS EXCLUSIVE lock and irreversibly removes all rows; with CASCADE the lock propagates to every FK-referencing table.

Safe rewrite

For ongoing data removal use a batched DELETE; reserve TRUNCATE for environments where downtime and data loss are acceptable.

Example

Try it in the playground →

Unsafe

TRUNCATE users;

Related