TRUNCATE statement 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.
The
TRUNCATE statement performs a schema change. For more information about how online schema changes work in CockroachDB, see Online Schema Changes.TRUNCATE is a schema change, and as such is not transactional. For more information about how schema changes work, see Online Schema Changes.
Synopsis
Required privileges
The user must have theDROP privilege on the table.
Parameters
Viewing schema changes
This schema change statement is registered as a job. You can view long-running jobs withSHOW JOBS.
Examples
Truncate a table (no foreign key dependencies)
Truncate a table and dependent tables
In these examples, theorders table has a Foreign Key relationship to the customers table. Therefore, it’s only possible to truncate the customers table while simultaneously truncating the dependent orders table, either using CASCADE or explicitly.

