The PostgreSQL TRUNCATE TABLE order is utilized to erase total information from a current table. You can likewise utilize DROP TABLE order to erase total table however it would eliminate total table design from the information base and you would have to re-make this table by and by on the off chance that you wish to store some information.
It has a similar impact as DELETE on each table, yet since it doesn't really examine the tables, it is quicker. Moreover, it recovers circle space promptly, instead of requiring an ensuing VACUUM activity. This is generally valuable on huge tables.
Syntax
The fundamental language structure of TRUNCATE TABLE is as per the following −
TRUNCATE TABLE table_name;
Example
Consider the COMPANY table has the accompanying records −
id | name | age | address | salary
----+-------+-----+------------+--------
1 | Paul | 32 | California | 20000
2 | Allen | 25 | Texas | 15000
3 | Teddy | 23 | Norway | 20000
4 | Mark | 25 | Rich-Mond | 65000
5 | David | 27 | Texas | 85000
6 | Kim | 22 | South-Hall | 45000
7 | James | 24 | Houston | 10000
(7 rows)
Coming up next is the guide to shorten −
testdb=# TRUNCATE TABLE COMPANY;
Presently, COMPANY table is shortened and the accompanying would be the yield of SELECT explanation −
testdb=# SELECT * FROM CUSTOMERS;
id | name | age | address | salary
----+------+-----+---------+--------
(0 rows)