使用更新表(UpdateTable)介面更新指定表的預留讀輸送量、預留寫輸送量、最大版本數等設定。

介面

    """
        說明:更新表屬性,目前只支援修改預留讀寫輸送量。
        ``table_name``是對應的表名。
        ``table_options``是``tablestore.metadata.TableOptions``類的樣本,它包含time_to_live,max_version和max_time_deviation三個參數。
        ``reserved_throughput``是``ots2.metadata.ReservedThroughput``類的執行個體,表示預留讀寫輸送量。

        返回:針對該表的預留讀寫輸送量的最近上調時間、最近下調時間和當天下調次數。

        ``update_table_response``表示更新的結果,是ots2.metadata.UpdateTableResponse類的執行個體。
        """
        def update_table(self, table_name, table_options, reserved_throughput):
			

樣本

更新表的最大版本數為5。

        # 設定新的預留讀輸送量為0,寫輸送量為0。
        reserved_throughput = ReservedThroughput(CapacityUnit(0, 0))

        # 建立TableOptions,資料保留31536000秒,超過後自動刪除;最大5個版本;寫入時指定的版本值和當前標準時間相差不能超過1天。
        table_options = TableOptions(31536000, 5, 86400)

        try:
            # 調用介面更新表的預留讀寫輸送量。
            ots_client.update_table('SampleTable', reserved_throughput)

            # 如果沒有拋出異常,則說明執行成功。
            print "update table succeeded"
        except Exception:
            # 如果拋出異常,則說明執行失敗,處理異常。
            print "update table failed"
			

詳細代碼請參見UpdateTable@GitHub