使用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);