This topic uses parameters and sample code to describe how to use Tablestore SDK for Go to update the configurations of a table. You can update the time to live (TTL), max versions, max version offset, and Stream configuration of a data table. You can also update the reserved read and write throughput of a data table in a high-performance instance.
API operation
UpdateTable(request *UpdateTableRequest) (*UpdateTableResponse, error)
Sample code
Update the configurations of a data table
Update the reserved throughput of a data table in a high-performance instance
The following sample code provides an example on how to update the configurations of a data table.
func UpdateTable(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
updateTableReq.TableOption.DeviationCellVersionInSec = 86400
updateTableReq.TableOption.AllowUpdate = proto.Bool(true)
_, err := client.UpdateTable(updateTableReq)
if (err != nil) {
fmt.Println("failed to update table with error:", err)
} else {
fmt.Println("update finished")
}
}
The following sample code provides an example on how to update the reserved throughput of a data table in a high-performance instance.
func UpdateTable(client *tablestore.TableStoreClient, tableName string) {
updateTableReq := new(tablestore.UpdateTableRequest)
updateTableReq.TableName = tableName
updateTableReq.ReservedThroughput = new(tablestore.ReservedThroughput)
updateTableReq.ReservedThroughput.Readcap = 1
updateTableReq.ReservedThroughput.Writecap = 1
_, err := client.UpdateTable(updateTableReq)
if (err != nil) {
fmt.Println("failed to update table with error:", err)
} else {
fmt.Println("update finished")
}
}
References
For more information about the API operation, see UpdateTable.
After you update the configurations of a table, you can perform the following operations: