This documentation is for the unreleased development version of jOOQ. Click on the above version links to get this documentation for a supported version of jOOQ.
The TRUNCATE statement
Applies to ✅ Open Source Edition ✅ Express Edition ✅ Professional Edition ✅ Enterprise Edition
Even if the
TRUNCATE statement mainly modifies data, it is generally considered to be a DDL statement. It is popular in many databases when you want to bypass constraints for table truncation. Databases may behave differently, when a truncated table is referenced by other tables. For instance, they may fail if records from a truncated table are referenced, even with
ON DELETE CASCADE clauses in place. Please, consider your database manual to learn more about its
TRUNCATE syntax is trivial:
TRUNCATE is not supported by all dialects. jOOQ will execute a
DELETE FROM AUTHOR statement instead, which is roughly equivalent.
This example using jOOQ:
Translates to the following dialect specific expressions:
-- ACCESS, FIREBIRD, SQLITE, TERADATA DELETE FROM AUTHOR -- ASE, AURORA_MYSQL, AURORA_POSTGRES, BIGQUERY, COCKROACHDB, DERBY, DUCKDB, EXASOL, H2, HANA, HSQLDB, INFORMIX, MARIADB, -- MEMSQL, MYSQL, ORACLE, POSTGRES, REDSHIFT, SNOWFLAKE, SQLDATAWAREHOUSE, SQLSERVER, SYBASE, TRINO, VERTICA, YUGABYTEDB TRUNCATE TABLE AUTHOR -- DB2 TRUNCATE TABLE AUTHOR IMMEDIATE