Este tópico descreve como atualizar as configurações de uma tabela com o Tablestore SDK for Java.
Pré-requisitos
Inicialize um cliente. Para mais informações, consulte Inicializar um cliente Tablestore.
Método
public UpdateTableResponse updateTable(UpdateTableRequest request) throws TableStoreException, ClientException
Código de exemplo
O exemplo a seguir mostra como atualizar as configurações da tabela test_table:
public static void updateTableExample(SyncClient client) {
UpdateTableRequest request = new UpdateTableRequest("test_table");
// Set the reserved read throughput to 0 CU and the reserved write throughput to 0 CU.
ReservedThroughput reservedThroughput = new ReservedThroughput(0, 0);
request.setReservedThroughputForUpdate(reservedThroughput);
TableOptions tableOptions = new TableOptions();
// Specify the maximum number of versions that can be retained for data in an attribute column.
tableOptions.setMaxVersions(3);
// Specify the TTL in seconds.
tableOptions.setTimeToLive(86400);
// Specify the max version offset in seconds.
tableOptions.setMaxTimeDeviation(86400);
// Specify whether to allow updates.
tableOptions.setAllowUpdate(false);
request.setTableOptionsForUpdate(tableOptions);
// Enable Stream and set the Stream validity period to seven days.
StreamSpecification streamSpecification = new StreamSpecification(true, 168);
request.setStreamSpecification(streamSpecification);
// Call the updateTable method to modify the table configurations.
client.updateTable(request);
}
Referências
Para mais informações, consulte Modificar as configurações de uma tabela de séries temporais.