All Products
Search
Document Center

Tablestore:Update table configurations

Last Updated:Aug 11, 2026

Use the Tablestore SDK for Go to update the TTL, maximum number of versions, maximum version offset, update permissions, Stream settings, and reserved throughput of a table.

Prerequisites

Install the Tablestore SDK for Go and initialize the client.

Description

Call UpdateTable to update the table properties, Stream settings, or reserved throughput of a table. Each request must specify at least one type of configuration.

func (tableStoreClient *TableStoreClient) UpdateTable(request *UpdateTableRequest) (*UpdateTableResponse, error)

The following sample updates the TTL, maximum number of versions, maximum version offset, and update permissions of the example_table table.

request := &tablestore.UpdateTableRequest{
    TableName: "example_table",
    TableOption: &tablestore.TableOption{
        TimeToAlive:               86400,
        MaxVersion:                3,
        DeviationCellVersionInSec: 86400,
        AllowUpdate:               proto.Bool(false),
    },
}

_, err := client.UpdateTable(request)
if err != nil {
    log.Fatal(err)
}

Parameters

UpdateTableRequest contains the following parameters.

Name

Type

Description

TableName (required)

string

The table name.

TableOption (optional)

*TableOption

The table properties to update.

StreamSpec (optional)

*StreamSpecification

The Stream settings.

ReservedThroughput (optional)

*ReservedThroughput

The reserved read/write throughput. Non-zero values apply only to high-performance instances in CU mode.

At least one of TableOption, StreamSpec, and ReservedThroughput is required.

Table options

TableOption contains the following parameters.

Name

Type

Description

TimeToAlive (optional)

int

The time to live (TTL), in seconds. A value of -1 indicates that data never expires. For other values, the minimum is 86400 (one day). Expired data is automatically deleted. To use a search index or secondary index, set this parameter to -1 or set AllowUpdate to false.

MaxVersion (optional)

int

The maximum number of versions retained for each attribute column. To use a search index or secondary index, set this parameter to 1.

DeviationCellVersionInSec (optional)

int64

The maximum version offset, in seconds. The difference between the timestamp of written data and the current system time must be within this range. Valid versions fall within [max(write time - maximum version offset, write time - TTL), write time + maximum version offset).

AllowUpdate (optional)

*bool

Specifies whether data can be updated by calling UpdateRow. If this parameter is set to false, data cannot be updated.

Important

UpdateFullRow can be configured only when a table is created. It cannot be modified by calling UpdateTable.

Stream settings

StreamSpec is of the StreamSpecification type and contains the following parameters.

Name

Type

Description

EnableStream (required)

bool

Specifies whether to enable Stream.

ExpirationTime (optional)

int32

The retention period of incremental logs, in hours. Maximum value: 168 (seven days). This parameter is required when EnableStream is set to true.

Important

When you modify the ExpirationTime parameter, you must also set EnableStream to true. Otherwise, the existing data channel becomes unavailable and affects data synchronization for the table's search index.

Reserved throughput

ReservedThroughput contains the following parameters.

Name

Type

Description

Readcap (optional)

int

The reserved read throughput, in CUs. Default value: 0.

Writecap (optional)

int

The reserved write throughput, in CUs. Default value: 0.

Examples

Update Stream settings

The following sample enables Stream for the example_table table and sets the incremental log retention period to 168 hours.

request := &tablestore.UpdateTableRequest{
    TableName: "example_table",
    StreamSpec: &tablestore.StreamSpecification{
        EnableStream:   true,
        ExpirationTime: 168,
    },
}

_, err := client.UpdateTable(request)
if err != nil {
    log.Fatal(err)
}