<@U0A71G31CDV> after what version TRUNCATE TABLE o...
# questions-and-troubleshooting
z
@Rocky after what version TRUNCATE TABLE on iceberg shared data is supported?
r
Support for the
TRUNCATE TABLE
command on Iceberg catalogs (external tables) is introduced in StarRocks version 4.1. In versions prior to 4.1 (such as 4.0.x), attempting to truncate an Iceberg table might result in errors (e.g., "Unknown database") or be unsupported. Starting from v4.1, you can use the statement to quickly clear all data from an Iceberg table while maintaining the table schema and metadata. Syntax Example
Copy code
sql
TRUNCATE TABLE iceberg_catalog.database_name.table_name;
Key Differences from DELETE * DELETE: Supported from v4.1 and later, allows for conditional row removal (using a
WHERE
clause). * TRUNCATE: Clears the entire table or specified partitions as a whole. It is generally more efficient for clearing data as it does not require filtering and does not impact query performance in the same way as large-scale deletions. References • data_source/catalog/iceberg/DML.md • release_notes/release-4.0.md • release_notes/release-3.5.md • release_notes/release-3.4.md • release_notes/release-3.2.md • release_notes/release-3.3.md
The
TRUNCATE TABLE
command has been supported in StarRocks for internal tables since its earliest versions (inherited from its origins as a fork of Doris). However, its support for External Tables and specific optimizations were introduced in the following versions: 1. Internal Tables * Duplicate, Aggregate, and Unique Key models: Supported since the earliest releases (v1.0+). * Primary Key model: Supported since the introduction of the Primary Key model in v1.19/v2.0. It is highly recommended to use
TRUNCATE TABLE
(or
TRUNCATE TABLE PARTITION
) instead of
DELETE
when clearing entire datasets, as it is a metadata-only operation and does not impact query performance. 2. External Tables (Data Lake) Support for truncating tables in external catalogs was added more recently: * Hive (Managed Tables): Supported since the introduction of the Hive Catalog (v2.4+). Note that only managed tables (not external ones) typically support truncation in Hive. * Paimon: Supported since v3.5. * Iceberg and External Hive Tables: Explicit support for
TRUNCATE TABLE
on external Hive and Iceberg tables was added in v4.1 (and optimized in late v3.3.x releases). Key Notes: * Recovery: Unlike
DROP TABLE
(which moves data to the trash for a period), data deleted via
TRUNCATE TABLE
cannot be recovered. * Performance:
TRUNCATE TABLE
is more efficient than
DELETE
because it clears data at the tablet/partition level directly rather than marking rows as deleted. * State Requirement: The table must be in the
NORMAL
state (e.g., no ongoing schema changes).