All Products
Search
Document Center

Tablestore:Delete a data table

Last Updated:Jun 28, 2024

You can call the DeleteTable operation to delete a data table from an instance.

Usage notes

  • You cannot restore deleted data tables. Proceed with caution.

  • When you delete a data table, the data in the data table and the secondary indexes that are created for the data table are deleted. You cannot restore deleted data and secondary indexes. Proceed with caution.

Prerequisites

API operation

DeleteTable(request *DeleteTableRequest) (*DeleteTableResponse, error)

Parameters

Parameter

Required

Description

TableName

Yes

The name of the data table. You can call the ListTable operation to query the names of all tables in an instance.

Examples

The following sample code provides an example on how to delete a data table:

func DeleteTableSample(client *tablestore.TableStoreClient, tableName string) {
    deleteReq := new(tablestore.DeleteTableRequest)
    deleteReq.TableName = tableName
    _, err := client.DeleteTable(deleteReq)
    if (err != nil) {
        fmt.Println("Failed to delete table with error:", err)
    } else {
        fmt.Println("Delete table finished")
    }
}           

References

  • For more information about the API operation, see DeleteTable. For the complete sample code, visit DeleteTable@GitHub.

  • If an error occurs when you call the operation, find the error cause in Error codes based on the error message and handle the error.