Todos os produtos
Search
Central de documentação

Tablestore:Consulta de informações de uma tabela

Última atualização: Jul 03, 2026

Este tópico descreve como consultar informações detalhadas de uma tabela com o SDK para PHP.

Pré-requisitos

Inicialize um cliente. Para mais informações, consulte Inicializar um cliente do Tablestore.

Descrição do método

public function describeTable(array $request)

Descrição do parâmetro $request

table_name (obrigatório) string: Nome da tabela.

Código de exemplo

O exemplo a seguir consulta as informações detalhadas da tabela test_table.

try{
    $response = $client->describeTable(array (
        'table_name' => 'test_table',
    ));

    // Table schema information.
    echo "* Table name: " . $response['table_meta']['table_name'] . "\n";
    echo "* Primary key information \n";
    foreach ($response['table_meta']['primary_key_schema'] as $primaryKey) {
        echo "{$primaryKey[0]}: {$primaryKey[1]} \n";
    }
    echo "* Predefined column information \n";
    foreach ($response['table_meta']['defined_column'] as $definedColumn) {
        echo "{$definedColumn[0]}: {$definedColumn[1]} \n";
    }

    // Table configuration information
    echo "* Table configuration information \n";
    echo "Time to live: " . $response['table_options']['time_to_live'] . "\n";
    echo "Max versions: " . $response['table_options']['max_versions'] . "\n";
    echo "Max version offset: " . $response['table_options']['deviation_cell_version_in_sec'] . "\n";
    echo "Whether to allow updates: " . ($response['table_options']['allow_update'] ? 'true' : "false") . "\n";

    // Table Stream information
    echo "* Whether to enable Stream: " . ($response['stream_details']['enable_stream'] ? 'true' : "false") . "\n";
    if($response['stream_details']['enable_stream']){
        echo "Stream expiration time: " . $response['stream_details']['expiration_time'] . "\n";
    }

    // Reserved read/write throughput of the table
    echo "* Reserved read/write throughput \n";
    echo "Reserved read throughput: " . $response['capacity_unit_details']['capacity_unit']['read'] . "\n";
    echo "Reserved write throughput: " . $response['capacity_unit_details']['capacity_unit']['write'] . "\n";

    // Secondary index information
    foreach ($response['index_metas'] as $indexMeta) {
        echo "* Secondary index name: " . $indexMeta['name'] . "\n";
        echo "Primary key columns: [" . implode(", ", $indexMeta['primary_key']) . "]\n";
        echo "Predefined columns: [" . implode(", ", $indexMeta['defined_column']) . "]\n";
        echo "Secondary index type: " . $indexMeta['index_type'] . "\n";
        echo "Secondary index update mode: " . $indexMeta['index_update_mode'] . "\n";
    }
} catch (Exception $e) {
    echo 'Describe table failed.';
}