All Products
Search
Document Center

Lindorm:TRUNCATE TABLE

Last Updated:Apr 18, 2024

You can use the TRUNCATE TABLE syntax to clear the data in a table with the schema and indexes of the table unchanged. The TRUNCATE TABLE syntax can be used to quickly delete the data in a table while ensuring the integrity of the table.

Applicable engines

The TRUNCATE TABLE syntax is applicable only to LindormTable.

Syntax

truncate_table_statement ::= TRUNCATE TABLE table_identifier

Usage notes

When you use the TRUNCATE TABLE syntax to clear the data in a table, take note of the following items:

  • If the version of SQL engine used by your instance is earlier than 2.6.10, you must use the OFFLINE TABLE syntax to set the table status to OFFLINE before you execute the TRUNCATE TABLE statement. If the version of SQL engine used by your instance is 2.6.10 or later, you can directly execute the TRUNCATE TABLE statement to clear the data in the table.

  • The TRUNCATE TABLE syntax does not delete the schema and indexes of a table.

Examples

Clear the data in the sensor table.

  • The following sample statements provide an example on how to use the TRUNCATE TABLE syntax to clear the data in a table when the SQL engine version is earlier than 2.6.10:

    --Set the status of the sensor table to OFFLINE first.
    OFFLINE TABLE sensor;
    
    --Clear the data in the sensor table.
    TRUNCATE TABLE sensor;
  • The following sample statement provides an example on how to use the TRUNCATE TABLE syntax to clear the data in a table when the SQL engine version is 2.6.10 or later:

    TRUNCATE TABLE sensor;