January 2002
Intermediate to advanced
640 pages
16h 39m
English
Empties the contents of a table.
TRUNCATE [ TABLE ] namenameThe name of the table you wish to truncate. To truncate a table means to remove all rows from the table.
TRUNCATEThe message returned if the specified table is successfully truncated.
ERROR: Relation 'name' does not existThe error returned if the specified table name does not exist in the connected database.
Use this command to remove all rows of a specified table. It does not scan through the
table before removing data, making it rather helpful when emptying large tables of data. In
essence, it is a quicker form of the DELETE command.
This example empties all of the rows in the temp_emp table:
booktown=# TRUNCATE TABLE temp_emp;
TRUNCATE