查询表信息

更新时间:
复制 MD 格式

使用 Python SDK 查询数据表的表结构、表配置、加密、预留读写吞吐量和二级索引信息。

前提条件

安装Tablestore Python SDK并初始化客户端。

功能说明

调用 describe_table 方法查询指定数据表,返回包含当前表信息的 DescribeTableResponse

def describe_table(self, table_name)

以下示例查询 example_table 并输出主要返回信息。

response = client.describe_table("example_table")

print("Table metadata:", response.table_meta)
print("Table options:", response.table_options)
print("Encryption settings:", response.sse_details)
print(
    "Reserved throughput:",
    response.reserved_throughput_details,
)
print("Secondary indexes:", response.secondary_indexes)

参数说明

describe_table 方法包含以下参数。

名称

类型

说明

table_name(必选)

str

数据表名称。

返回值

DescribeTableResponse 包含以下业务信息。

字段

类型

说明

table_meta

TableMeta

数据表结构,包括数据表名称、主键列和预定义列。

table_options

TableOptions

表配置,包括数据生命周期、最大版本数、有效版本偏差和是否允许更新。

reserved_throughput_details

ReservedThroughputDetails

当前预留读写吞吐量,以及最近一次上调和下调的时间。

secondary_indexes

List[SecondaryIndexMeta]

二级索引信息,包括索引名称、主键列、预定义列和索引类型。

sse_details

SSEDetails

服务端加密配置,包括启用状态、密钥类型、密钥 ID 和 RAM 角色 ARN。