Delete a secondary index
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. |
Examples
The following sample code deletes two global secondary indexes from a data table in a single call:
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);
}