Use Tablestore SDK for Java to delete a global or local secondary index without affecting the data table or its data.
Prerequisites
Install the Tablestore SDK for Java and initialize the client.
Feature description
Call deleteIndex to delete a global or local secondary index from a data table. The operation deletes only the target index and does not delete the data table or its data.
public DeleteIndexResponse deleteIndex(DeleteIndexRequest deleteIndexRequest)
throws TableStoreException, ClientException
A deleted secondary index cannot be recovered. To use the index again, create a new secondary index.
The following example deletes the example_index secondary index from the example_table data table.
DeleteIndexRequest request =
new DeleteIndexRequest("example_table", "example_index");
DeleteIndexResponse response = client.deleteIndex(request);
System.out.println(response.getRequestId());
After the request succeeds, call describeTable and verify that the returned indexMeta no longer contains the target index.
Parameters
DeleteIndexRequest contains the following parameters.
|
Name |
Type |
Description |
|
mainTableName (required) |
|
The name of the data table. |
|
indexName (required) |
|
The name of the secondary index to delete. |