Call the DeleteIndex operation to delete a secondary index from a data table. Once deleted, the index cannot be restored.
Prerequisites
-
An OTSClient instance is initialized. For more information, see Initialize a Tablestore client.
-
A secondary index is created. For more information, see Create a secondary index.
Usage notes
Deleted secondary indexes cannot be restored. To use the index again, recreate it.
Parameters
|
Parameter |
Description |
|
MainTableName |
The name of the data table. |
|
IndexName |
The name of the index table. |
Example
This example deletes a secondary index from a data 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 the secondary index: ", err)
} else {
fmt.Println("Successfully deleted the secondary index: ", resp)
}
}