If you no longer need a secondary index that is created for a data table, you can call the DeleteIndex operation to delete the secondary index.
Prerequisites
An OTSClient instance is initialized. For more information, see Initialize an OTSClient instance.
A secondary index is created. For more information, see Create a secondary index.
Usage notes
Deleted secondary indexes cannot be restored. If you need to use the secondary index after you delete it, you need to create the secondary index again.
Parameters
Parameter | Description |
MainTableName | The name of the data table. |
IndexName | The name of the index table. |
Examples
The following sample code provides an example on how to delete an index table:
func DeleteIndex(client *tablestore.TableStoreClient, tableName string, indexName string) {
deleteIndex := &tablestore.DeleteIndexRequest{ MainTableName:tableName, IndexName: indexName }
resp, err := client.DeleteIndex(deleteIndex)
if err != nil {
fmt.Println("Failed to delete index:", err)
} else {
fmt.Println("drop index finished", resp)
}
}