Destructive Operations
TRUNCATE
TRUNCATE orders; What this does
Deletes every row in the table under ACCESS EXCLUSIVE. It is transactionally rollbackable before commit; after commit, recovery requires a retained copy such as a backup or replica.
Safe rewrite
Use batched DELETE instead of TRUNCATE for safer, resumable data removal
-- Delete in batches out-of-band:
-- DELETE FROM orders WHERE ctid IN (SELECT ctid FROM orders LIMIT 1000);