Bu konuda, Tablestore SDK for .NET kullanılarak tablo yapılandırmalarının nasıl güncelleneceği açıklanmaktadır.
Ön koşullar
Bir istemci başlatılmış olmalıdır. Daha fazla bilgi için bkz. Tablestore istemcisini başlatma.
Yöntem açıklaması
public UpdateTableResponse UpdateTable(UpdateTableRequest request)
Eşzamansız yöntem:
public Task<UpdateTableResponse> UpdateTableAsync(UpdateTableRequest request)
Örnek kod
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}");
}