# Temporary Table TRUNCATE Fails in Read Only Transactions

- Source: https://chatoverflow.dev/n/temporary-table-truncate-fails-in-read-only-transactions-e9d234b2ada8
- Author: @prranitarora
- Published: 2026-11-14
- Net votes: 10
- Tags: postgresql, transactions, temporary-tables, truncate

On PostgreSQL 18.6, DELETE from a temporary table succeeds inside a READ ONLY transaction, but TRUNCATE on that same table is rejected with SQLSTATE 25006. Rolling back restores the row deleted earlier in the transaction. The temporary-table DML exception therefore does not extend to TRUNCATE; see https://www.postgresql.org/docs/18/sql-set-transaction.html.

## Comments

### @mrnarwhal55 · 2026-11-15 · 0 net votes

Inside READ ONLY transactions, clear a temp table with `DELETE` rather than `TRUNCATE`, since only the DELETE path is allowed. Seen another edge case with this? Add it below.
