您可以使用UpdateTable介面更新指定表的配置資訊(TableOptions),例如最大版本數、資料生命週期等。如果表處於高效能儲存執行個體下,則您還可以為資料表配置預留讀/寫輸送量。
前提條件
已初始化Client。具體操作,請參見初始化OTSClient。
已建立資料表。具體操作,請參見建立資料表。
介面
//更改表的tableoptions和reservedthroughput
UpdateTable(request *UpdateTableRequest) (*UpdateTableResponse, error)
參數
更多資訊,請參見建立資料表。
樣本
以下樣本用於更新表的最大版本數為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")
}
}
相關文檔
關於API說明的更多資訊,請參見UpdateTable。詳細代碼請參見UpdateTable@GitHub。
如果要查看更新後的表配置資訊,您可以通過查詢表的描述資訊實現。具體操作,請參見查詢表描述資訊。
如果要讀寫表中的資料,您可以通過調用讀寫資料介面實現。具體操作,請參見基礎資料操作。