--- title: TRUNCATE summary: The TRUNCATE statement deletes all rows from specified tables. toc: true --- The `TRUNCATE` [statement](sql-statements.html) removes all rows from a table. At a high level, it works by dropping the table and recreating a new table with the same name. {{site.data.alerts.callout_info}} For smaller tables (with less than 1000 rows), using a [`DELETE` statement without a `WHERE` clause](delete.html#delete-all-rows) will be more performant than using `TRUNCATE`. {{site.data.alerts.end}} {% include {{{ page.version.version }}/misc/schema-change-stmt-note.md %} ## Synopsis
CASCADE truncates all dependent tables without listing them, which can lead to inadvertent and difficult-to-recover losses. To avoid potential harm, we recommend truncating tables explicitly in most cases. See Truncate Dependent Tables Explicitly for more details.{{site.data.alerts.end}}
{% include copy-clipboard.html %}
~~~ sql
> TRUNCATE customers;
~~~
~~~
pq: "customers" is referenced by foreign key from table "orders"
~~~
{% include copy-clipboard.html %}
~~~ sql
> TRUNCATE customers CASCADE;
~~~
{% include copy-clipboard.html %}
~~~ sql
> SELECT * FROM customers;
~~~
~~~
+----+-------+
| id | email |
+----+-------+
+----+-------+
(0 rows)
~~~
{% include copy-clipboard.html %}
~~~ sql
> SELECT * FROM orders;
~~~
~~~
+----+----------+------------+
| id | customer | orderTotal |
+----+----------+------------+
+----+----------+------------+
(0 rows)
~~~
#### Truncate dependent tables explicitly
{% include copy-clipboard.html %}
~~~ sql
> TRUNCATE customers, orders;
~~~
{% include copy-clipboard.html %}
~~~ sql
> SELECT * FROM customers;
~~~
~~~
+----+-------+
| id | email |
+----+-------+
+----+-------+
(0 rows)
~~~
{% include copy-clipboard.html %}
~~~ sql
> SELECT * FROM orders;
~~~
~~~
+----+----------+------------+
| id | customer | orderTotal |
+----+----------+------------+
+----+----------+------------+
(0 rows)
~~~
## See also
- [`DELETE`](delete.html)
- [`SHOW JOBS`](show-jobs.html)
- [Foreign Key constraint](foreign-key.html)
- [Online Schema Changes](online-schema-changes.html)