Este tópico descreve como atualizar as configurações de tabela com o Tablestore SDK for .NET.
Pré-requisitos
Inicialize um cliente. Para mais informações, consulte Inicializar um cliente Tablestore.
Descrição do método
public UpdateTableResponse UpdateTable(UpdateTableRequest request)
Método assíncrono:
public Task<UpdateTableResponse> UpdateTableAsync(UpdateTableRequest request)
Código de exemplo
try
{
UpdateTableRequest request = new UpdateTableRequest("test_table");
// Table configuration information.
TableOptions tableOptions = new TableOptions();
// Specify the TTL in seconds.
tableOptions.TimeToLive = 86400;
// Specify the maximum number of versions.
tableOptions.MaxVersions = 3;
// Specify the maximum version offset in seconds.
tableOptions.DeviationCellVersionInSec = 86400;
// Specify whether updates are allowed.
tableOptions.AllowUpdate = false;
request.TableOptions = tableOptions;
// Enable Stream and set the Stream validity period to seven days.
StreamSpecification streamSpecification = new StreamSpecification(true);
streamSpecification.ExpirationTime = 168;
request.StreamSpecification = streamSpecification;
// Set reserved read throughput to 0 CU and reserved write throughput to 0 CU (you can set this parameter to a non-zero value and the setting takes effect only for data tables in high-performance instances in CU mode).
CapacityUnit reservedThroughput = new CapacityUnit(0, 0);
request.ReservedThroughput = reservedThroughput;
// Call the UpdateTable method to modify the table configurations.
client.UpdateTable(request);
Console.WriteLine("Update table succeeded.");
}
catch (Exception ex)
{
Console.WriteLine($"Update table failed, exception:{ex.Message}");
}