For AI agents: the complete documentation index is at llms.txt. Every page is also available as markdown by appending .md to its URL, or by sending an Accept: text/markdown request header.

TRUNCATE TABLE keyword

TRUNCATE TABLE permanently deletes the contents of a table without deleting the table itself.

Syntax​

TRUNCATE TABLE [IF EXISTS] tableName;

IF EXISTS​

An optional IF EXISTS clause may be added directly after the TRUNCATE TABLE keywords to indicate that the selected table should be truncated only if it exists. Without IF EXISTS, QuestDB will throw an error if the table does not exist.

Notes​

This command irremediably deletes the data in the target table. In doubt, make sure you have created backups of your data.

Examples​

TRUNCATE TABLE trades;

This example will not throw an error, even if the table does not exist:

TRUNCATE TABLE IF EXISTS trades_non_existent;

See also​

To delete both the data and the table structure, use DROP.