Removes all rows from a table while preserving its schema and indexes.
Applicable engines
LindormTable
Syntax
TRUNCATE TABLE table_identifierUsage notes
SQL engine 2.6.10 or later: Run
TRUNCATE TABLEdirectly.SQL engine earlier than 2.6.10: Set the table to OFFLINE status using
OFFLINE TABLEbefore runningTRUNCATE TABLE.
TRUNCATE TABLE removes all row data but does not delete the table schema or indexes.
Examples
The following examples clear all data from the sensor table.
SQL engine 2.6.10 or later
TRUNCATE TABLE sensor;SQL engine earlier than 2.6.10
-- Set the table to OFFLINE first.
OFFLINE TABLE sensor;
-- Clear all data from the table.
TRUNCATE TABLE sensor;