TRUNCATE TABLE is a very quick way to delete all rows in a table. However,
TRUNCATE TABLE is not permitted when there are FK referring to the table,
and for a very good reason: TRUNCATE TABLE is fast because it does not
look at the data in the table, it just deallocates all pages allocated to the
But there is one special case that TRUNCATE TABLE ought to consider: all
referring tables are empty. That would permit you to run TRUNCATE TABLE
on a set of tables as long as you truncate them in the right order. Examining
whether a table is empty or not is a quick operations in most cases.
This suggestion is similar to
but with my suggestion you would not have to fiddle with enabling/disabling
constraints. On other hand, the suggestion in 251876 covers the situation when
you want to truncate a single table and reload it.