How to Truncate a Table

Truncating a table is a fast way to delete all the records in the table, however it is not 100% equivalent to deleting all the records. The statement to truncate a table is:

truncate employee;

In Postgres the differences between truncate a table and delete all rows in a table are:

  • Truncate does not fire delete triggers if they exist.
  • Truncate is more efficient in terms of response time
  • In Postgres delete needs a vacuum after finishing, truncate does not need a vacuum.

IN THIS PAGE