Skip to content

Latest commit

 

History

History
21 lines (16 loc) · 567 Bytes

truncate-all-rows.md

File metadata and controls

21 lines (16 loc) · 567 Bytes

Truncate All Rows

Given a postgres database, if you want to delete all rows in a table, you can use the DELETE query without any conditions.

> delete from pokemons;
DELETE 151

Though DELETE can do the job, if you really are deleting all rows to clear out a table, you are better off using TRUNCATE. A TRUNCATE query will be faster than a DELETE query because it will just delete the rows without scanning them as it goes.

> truncate pokemons;
TRUNCATE TABLE

source