All Products
Search
Document Center

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

Last Updated:Oct 21, 2020

You can delete all data from a table by using one of the following methods: 1. Delete the table and create a table that has the same name. 2. Obtain information about the primary key of the table. Then, delete the data in the table.

  • Delete a table and create a table of the same schema

    To delete a table, you can use Tablestore SDKs to call the DeleteTable operation. You can also delete a table in the Tablestore console. After you delete the table, you must create a table that has the same schema.

    Note
    • If the table has indexes, you must delete the indexes before you delete the table.

    • After the indexes of the table are deleted, you must create indexes for the created table if you want to use indexes.

  • Obtain the primary keys of all rows in the table to delete data from the table

    Obtain the primary keys of all rows in a table by using Tablestore SDK to call the GetRange operation. And then call the BatchWriteRow or DeleteRow operation to delete all data from the table.