PostgreSQL Truncate Command

PostgreSQL Truncate Command: TRUNCATE quickly removes all rows from a set of tables. It has the same effect as an unqualified DELETE on each table, but since it does not actually scan the tables it is faster. Furthermore, it reclaims disk space immediately, rather than requiring a subsequent VACUUM operation. This is most useful on large tables.

Syntax:

TRUNCATE [ TABLE ] [ ONLY ] name [ * ] [, … ]
[ RESTART IDENTITY | CONTINUE IDENTITY ] [ CASCADE | RESTRICT ]

Example:
Truncate all rows from student table.

PostgreSQL Truncate Command

Powered by k2schools