All Products
Search
Document Center

Tablestore:How do I delete all data from a data table?

Last Updated:Aug 09, 2024

To delete all data from a data table, you can delete the data table and create a data table with the same schema, or query the primary key of all rows in the data table and delete the rows based on the primary key.

  • Delete a data table and create a data table with the same schema

    You can use Tablestore SDKs to call the DeleteTable operation or use the Tablestore console to delete a data table. After you delete the data table, you must create a data table with the same schema.

    Note
    • If search indexes are created for the data table, you must delete the search indexes before you delete the data table. For more information, see Delete a search index.

    • If you want to use the indexes after the indexes are deleted, you can create indexes with the same schemas for the data table after you create the data table. For more information, see Create a search index and Usage methods.

  • Query the primary key of all rows in the data table and delete the rows

    You can query the primary key of all rows in the data table by using a Tablestore SDK to call the GetRange operation. Then, you can call the BatchWriteRow or DeleteRow operation to delete the rows.