通过 Python SDK调用 update_table() 方法,更新数据表的生命周期、最大版本数、有效版本偏差和预留读写吞吐量等配置。
前提条件
已初始化 Client。详情请参见初始化Tablestore Client。
方法说明
def update_table(self, table_name, table_options=None, reserved_throughput=None)
示例代码
以下示例更新 test_table 表的配置信息。
# 配置表参数:生命周期 1 天、最大版本数 3、有效版本偏差 1 天、禁止更新
table_options = TableOptions(time_to_live=86400, max_version=3, max_time_deviation=86400, allow_update=False)
# 设置预留读写吞吐量为 0 CU(仅 CU 模式高性能实例支持设置非零值)
reserved_throughput = ReservedThroughput(CapacityUnit(0,0))
try:
client.update_table('test_table', table_options, reserved_throughput)
print("Update table succeeded.")
except Exception as e:
print("Update table failed. %s" % e)
相关文档
该文章对您有帮助吗?