本文介紹如何通過 .NET SDK 更新表的配置資訊。
前提條件
方法說明
public UpdateTableResponse UpdateTable(UpdateTableRequest request)
非同步方法呼叫:
public Task<UpdateTableResponse> UpdateTableAsync(UpdateTableRequest request)
範例程式碼
try
{
UpdateTableRequest request = new UpdateTableRequest("test_table");
// 表配置資訊
TableOptions tableOptions = new TableOptions();
// 設定資料生命週期,單位為秒
tableOptions.TimeToLive = 86400;
// 設定最大版本數
tableOptions.MaxVersions = 3;
// 設定有效版本偏差,單位為秒
tableOptions.DeviationCellVersionInSec = 86400;
// 設定是否允許更新
tableOptions.AllowUpdate = false;
request.TableOptions = tableOptions;
// 開啟Stream資訊,並設定Stream到期時間為7天
StreamSpecification streamSpecification = new StreamSpecification(true);
streamSpecification.ExpirationTime = 168;
request.StreamSpecification = streamSpecification;
// 設定預留讀為0CU,預留寫為0CU(僅CU模式高效能執行個體支援設定資料表的預留讀寫輸送量為非零值)
CapacityUnit reservedThroughput = new CapacityUnit(0, 0);
request.ReservedThroughput = reservedThroughput;
// 調用UpdateTable方法修改表配置
client.UpdateTable(request);
Console.WriteLine("Update table succeeded.");
}
catch (Exception ex)
{
Console.WriteLine($"Update table failed, exception:{ex.Message}");
}