The TRUNCATE TABLE statement deletes all data from a table. In Lindorm 2.2.16 and later, you must run OFFLINE TABLE before you run TRUNCATE TABLE to prevent accidental data deletion.
Applicable engines
The TRUNCATE TABLE syntax is applicable only to the wide-table engine.
Syntax
truncate_table_statement ::= TRUNCATE TABLE table_identifierUsage notes
When you use the TRUNCATE TABLE statement to clear table data, note the following:
If the SQL engine version is earlier than 2.6.10, you must run
OFFLINE TABLEbefore you runTRUNCATE TABLE. If the SQL engine version is 2.6.10 or later, you can run theTRUNCATE TABLEstatement directly. The system automatically runs OFFLINE in the background. For information about how to check the current SQL engine version, see SQL engine versions.TRUNCATE TABLEretains the table structure and indexes.
When you run a TRUNCATE operation, we recommend that you stop online traffic first or run it during off-peak hours. Otherwise, the table operation may cause short-term request errors.
Examples
Clear the data in the sensor table.
For SQL engine versions earlier than 2.6.10, the following is an example:
-- Take the sensor table offline OFFLINE TABLE sensor; -- Clear the data in the sensor table TRUNCATE TABLE sensor;For SQL engine versions 2.6.10 or later, the following is an example:
TRUNCATE TABLE sensor;