All Products
Search
Document Center

Tablestore:Delete a secondary index

Last Updated:Apr 30, 2026

Call the DeleteIndex operation to delete a secondary index from a data table. Once deleted, the index cannot be restored.

Prerequisites

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)
    }
}