使用DescribeTable接口可以查询指定表的结构、预留读/写吞吐量详情等信息。

说明 API说明请参见DescribeTable

前提条件

  • 已初始化Client。更多信息,请参见初始化
  • 已创建数据表。

接口

/**
 * 获取一个表的信息,包括表的结构信息、配置信息、预留读/写吞吐量详情和Stream设置信息。
 * @api
 * @param [] $request 请求参数。
 * @return [] 请求返回。
 * @throws OTSClientException 当参数检查出错或服务端返回校验出错时抛出异常。
 * @throws OTSServerException 当OTS服务端返回错误时抛出异常。
 */
public function describeTable(array $request);

参数

  • 请求参数
    参数 说明
    table_name 表名。
  • 请求格式
    $result = $client->describeTable([
         'table_name' => '<string>', //设置表名,必须设置。
    ]);
  • 返回参数
    参数 说明
    table_meta 表的结构信息,包括如下内容:
    • table_name:表名称。
    • primary_key_schema:表的主键定义,与创建数据表时的主键定义相同。
    • defined_column:表的预定列定义。
    capacity_unit_details 表的预留读写吞吐量配置详情,包括如下内容:
    • capacity_unit表示表的预留读/写吞吐量配置信息,与计费相关。单位为CU
      • read:预留读吞吐量
      • write:预留写吞吐量
    • last_increase_time:最近一次上调该数据表的预留读写吞吐量设置的时间,使用UTC秒数表示。
    • last_decrease_time:最近一次下调该数据表的预留读写吞吐量设置的时间,使用UTC秒数表示。
    table_options 表的配置信息,包括如下内容:
    • time_to_live:数据生命周期,即数据的过期时间。
    • max_versions:最大版本数,即属性列能够保留数据的最大版本个数。
    • deviation_cell_version_in_sec:有效版本偏差,即写入数据的时间戳与系统当前时间的偏差允许最大值。
    stream_details 数据表的Stream信息,包括如下内容:
    • enable_stream:数据表是否打开Stream。
    • stream_id:数据表的Stream ID。
    • expiration_time:Stream的过期时间,较早的修改记录将会被删除,单位为小时。
    • last_enable_time:Stream的打开的时间。
  • 结果格式
    [
        'table_meta' => [
            'table_name' => '<string>',
            'primary_key_schema' => [
                ['<string>', <PrimaryKeyType>],
                ['<string>', <PrimaryKeyType>, <PrimaryKeyOption>]
            ],
            'defined_column'=> [
                ['<string>', <DefinedColumnType>] 
            ]
        ],
        'capacity_unit_details' => [
            'capacity_unit' => [
                'read' => <integer>,
                'write' => <integer>
            ],
            'last_increase_time' => <integer>,
            'last_decrease_time' => <integer>
        ],
        'table_options' => [
            'time_to_live' => <integer>,
            'max_versions' => <integer>,
            'deviation_cell_version_in_sec => <integer>
        ],
        'stream_details' => [
            'enable_stream' => true || false,
            'stream_id' => '<string>',
            'expiration_time' => <integer>,
            'last_enable_time' => <integer>
        ]
    ]        

示例

获取表的描述信息。

$result = $client->describeTable([
        'table_name' => 'mySampleTable',
        ]);
        var_dump($result);