本文介绍如何通过 Java SDK 更新表的配置信息。
前提条件
方法说明
public UpdateTableResponse updateTable(UpdateTableRequest request) throws TableStoreException, ClientException
示例代码
以下示例代码用于修改test_table表的配置信息。
public static void updateTableExample(SyncClient client) {
UpdateTableRequest request = new UpdateTableRequest("test_table");
// 设置预留读为50CU,预留写为20CU
ReservedThroughput reservedThroughput = new ReservedThroughput(50, 20);
request.setReservedThroughputForUpdate(reservedThroughput);
TableOptions tableOptions = new TableOptions();
// 设置最大版本数
tableOptions.setMaxVersions(3);
// 设置数据生命周期,单位为秒
tableOptions.setTimeToLive(86400);
// 设置有效版本偏差,单位为秒
tableOptions.setMaxTimeDeviation(86400);
// 设置是否允许更新
tableOptions.setAllowUpdate(false);
request.setTableOptionsForUpdate(tableOptions);
// 开启Stream信息,并设置Stream过期时间为7天
StreamSpecification streamSpecification = new StreamSpecification(true, 168);
request.setStreamSpecification(streamSpecification);
// 调用updateTable方法修改表配置
client.updateTable(request);
}
相关文档
该文章对您有帮助吗?