このトピックでは、Tablestore SDK for Java を使用してテーブルの構成を更新する方法について説明します。
前提条件
クライアントが初期化されていること。 詳細については、「Tablestore クライアントを初期化する」をご参照ください。
メソッド
public UpdateTableResponse updateTable(UpdateTableRequest request) throws TableStoreException, ClientExceptionサンプルコード
次のサンプルコードは、test_table テーブルの構成を更新する方法の例を示しています。
public static void updateTableExample(SyncClient client) {
UpdateTableRequest request = new UpdateTableRequest("test_table");
// 予約済み読み取りスループットを 50 CU、予約済み書き込みスループットを 20 CU に設定します。
ReservedThroughput reservedThroughput = new ReservedThroughput(50, 20);
request.setReservedThroughputForUpdate(reservedThroughput);
TableOptions tableOptions = new TableOptions();
// 属性列のデータに対して保持できる最大バージョン数を指定します。
tableOptions.setMaxVersions(3);
// TTL を秒単位で指定します。
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);
}関連情報
詳細については、「時系列テーブルの構成を変更する」をご参照ください。