You can call the UpdateTable operation to update the configuration information about a table, such as the max versions and time to live (TTL). You can also specify the reserved read throughput and the reserved write throughput for a data table in a high-performance instance.
Prerequisites
An OTSClient instance is initialized. For more information, see Initialize an OTSClient instance.
A data table is created. For more information, see Create a data table.
API operation
// Update the configurations of tableoptions and reservedthroughput for a table.
UpdateTable(request *UpdateTableRequest) (*UpdateTableResponse, error)
Parameters
For more information, see Create a data table.
Examples
The following sample code provides an example on how to update the max versions of a table to 5:
func UpdateTableMaxVersionSample(client *tablestore.TableStoreClient, tableName string) {
updateTableReq := new(tablestore.UpdateTableRequest)
updateTableReq.TableName = tableName
updateTableReq.TableOption = new(tablestore.TableOption)
updateTableReq.TableOption.TimeToAlive = -1
updateTableReq.TableOption.MaxVersion = 5
_, err := client.UpdateTable(updateTableReq)
if (err != nil) {
fmt.Println("failed to update table with error:", err)
} else {
fmt.Println("update finished")
}
}
References
For information about the API operation that you can call to update a table, see UpdateTable. For the detailed sample code, visit UpdateTable@GitHub.
You can query the description of a table to view the updated configuration information about the table. For more information, see Query the description of a table.
You can call API operations to read and write data in a data table. For more information, see Basic operations on data.