Preamble

PostgreSQL TRUNCATE TABLE statement is used to remove (truncate) all records from a table or set of tables in PostgreSQL. It performs the same function as the DELETE operator, without the WHERE operator.
Warning: If you truncate a table, the TRUNCATE TABLE operator cannot be overridden if it is not in a transaction that was not committed.
The syntax for TRUNCATE TABLE statement in PostgreSQL
TRUNCATE [TABLE] [ONLY] [schema_name.]table_name [*] [,...]
[ RESTART IDENTITY | CONTINUE IDENTITY ]
[ CASCADE | LIMIT] ;
Parameters and arguments of the statement
- TABLE – Optional. The truncate operator will behave identically regardless of whether you specified a TABLE or not.
- ONLY – Optional. If specified, the only table_name will be truncated. If not specified, table_name and all its child tables will be truncated.
- schema_name – The name of the scheme to which the table belongs.
- Table_name – The table that you want to be truncated.
- * – Optional. If specified, table_name and all his child tables will be truncated.
- RESTART IDENTITY – Optional. If specified, all sequences in the truncated tables will be reset.
- CONTINUE IDENTITY – Optional. If specified, all the sequences in the truncated tables will be left and will not be reset. This is the default behavior.
- CASCADE – Optional. If specified, all tables that have an external key reference to table_name will also be truncated.
- RESTRICT – Optional. If specified, all tables that have an external key reference to table_name will not be truncated if they were not listed in the TRUNCATE TABLE operator. This is the default behavior.
Note:
- Before you can truncate the table, you must have the necessary privileges such as TRUNCATE.
- DELETE triggers for a table do not start during truncation.
You cannot truncate a table that is referenced by a foreign key unless the TRUNCATE command lists all tables in relation to the foreign key.
The entire truncated row storage will be restored without VACUUM.
In PostgreSQL, the truncation of a table is a quick way to remove records from a table because you don’t need to scan the table to do so. Truncation of a table is also much easier than removing a table and recreating it.
An example of using the TRUNCATE TABLE operator in PostgreSQL
For example:
TRUNCATE ONLY products;
In this example, the table with the name of the products will be truncated and all records from this table will be deleted.
This would be equivalent to the next DELETE operator in PostgreSQL
DELETE FROM products;
Both of these operators will remove all data from the products table, and since the ONLY keyword was used in the TRUNCATE command, no descendant tables will be truncated. It is always safer to specify the ONLY keyword to avoid accidentally truncating the descendant tables.
Several tables
Next, let’s look at how to truncate several tables at once.
For example:
TRUNCATE ONLY products, inventory;
In this example, the tables with the names of products and inventory will be truncated. Again, we have enabled the ONLY keyword so that no descendant tables are truncated.
Resetting columns of identifiers
By default, when you truncate a table, the ID columns continue numbering from where it stopped. You can specify PostgreSQL to automatically reset all identifier columns when you truncate a table by enabling the RESTART IDENTITY option.
For example:
TRUNCATE ONLY inventory
RESTART IDENTITY;
In this example, the identifier columns in the inventory table will return to their original values. This is useful if you have a primary key field that you want to restart with 1.
PostgreSQL Tutorial for Beginners; PostgreSQL TRUNCATE TABLE Statement
Enteros
About Enteros
IT organizations routinely spend days and weeks troubleshooting production database performance issues across multitudes of critical business systems. Fast and reliable resolution of database performance problems by Enteros enables businesses to generate and save millions of direct revenue, minimize waste of employees’ productivity, reduce the number of licenses, servers, and cloud resources and maximize the productivity of the application, database, and IT operations teams.
The views expressed on this blog are those of the author and do not necessarily reflect the opinions of Enteros Inc. This blog may contain links to the content of third-party sites. By providing such links, Enteros Inc. does not adopt, guarantee, approve, or endorse the information, views, or products available on such sites.
Are you interested in writing for Enteros’ Blog? Please send us a pitch!
RELATED POSTS
From Data to Delivery: How Enteros Transforms D2C Brands Through Database Performance and Cloud FinOps
- 6 October 2025
- Database Performance Management
Introduction In the fast-evolving world of Direct-to-Consumer (D2C) brands, agility and performance are everything. D2C businesses thrive on personalization, speed, and customer trust — all of which depend on how efficiently data flows through their systems. Behind every product recommendation, every smooth checkout, and every on-time delivery is a complex network of databases, cloud infrastructure, … Continue reading “From Data to Delivery: How Enteros Transforms D2C Brands Through Database Performance and Cloud FinOps”
How Enteros AI Performance and Data Lake Optimization Are Powering Innovation in the Fashion Industry
Introduction The fashion industry, once ruled by instinct and creativity alone, is now undergoing a seismic transformation driven by data and artificial intelligence (AI). From forecasting trends to managing supply chains and customer experiences, data-driven insights are redefining how fashion brands operate. Central to this digital shift is the use of AI-driven performance management and … Continue reading “How Enteros AI Performance and Data Lake Optimization Are Powering Innovation in the Fashion Industry”
When Booking Systems Freeze: The Hidden IT Challenge Behind Aviation Disruptions
Behind every on-time departure, there’s an invisible network of data systems working in sync.But when that synchronization breaks — even for a few seconds — the result can ground entire fleets. The Hidden Digital Backbone of Aviation Today’s airlines and airport operators depend on complex ecosystems that process millions of real-time transactions per minute: Flight … Continue reading “When Booking Systems Freeze: The Hidden IT Challenge Behind Aviation Disruptions”
How Enteros AIOps and Generative AI Are Powering the Cloud Center of Excellence for Modern Banking
- 5 October 2025
- Database Performance Management
Introduction The modern banking industry is being reshaped by digital innovation. Artificial Intelligence (AI), automation, and cloud computing are no longer optional — they are the driving forces behind operational efficiency, customer personalization, and financial growth. Amid this technological transformation, banks are building Cloud Centers of Excellence (CCoE) to unify their cloud strategies, improve governance, … Continue reading “How Enteros AIOps and Generative AI Are Powering the Cloud Center of Excellence for Modern Banking”