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 multiple secondary indexes that are created for a data table at the same time:
public static void DeleteGlobalIndex()
{
OTSClient otsClient = Config.GetClient();
Console.WriteLine("Start delete globalIndex...");
DeleteGlobalIndexRequest request = new DeleteGlobalIndexRequest(TableName, IndexName);
otsClient.DeleteGlobalIndex(request);
DeleteGlobalIndexRequest request2 = new DeleteGlobalIndexRequest(TableName, IndexName2);
otsClient.DeleteGlobalIndex(request2);
Console.WriteLine("Global Index is deleted,tableName: " + TableName + ",IndexName:" + IndexName + "," + IndexName2);
}