This topic describes how to delete a data table from an instance by using Tablestore SDK for Go.
Usage notes
If a search index is created for a data table, you must delete the search index before you delete the data table.
If a secondary index is created for a data table, the secondary index is automatically deleted when you delete the data table.
Deleted data tables and secondary indexes cannot be restored. Proceed with caution.
Prerequisites
A client is initialized. For more information, see Initialize a Tablestore client.
Method description
func (tableStoreClient *TableStoreClient) DeleteTable(request *DeleteTableRequest) (*DeleteTableResponse, error)Sample code
The following sample code demonstrates how to delete a data table named test_table.
func DeleteTableSample(client *tablestore.TableStoreClient) {
deleteRequest := new(tablestore.DeleteTableRequest)
deleteRequest.TableName = "test_table"
_, err := client.DeleteTable(deleteRequest)
if (err != nil) {
fmt.Println("Failed to delete table with error:", err)
} else {
fmt.Println("Delete table finished.")
}
}