Todos los productos
Search
Centro de documentos

Tablestore:Query information of a table

Última actualización: Sep 03, 2026

Este tema describe cómo consultar información detallada de una tabla mediante el SDK de PHP.

Requisitos previos

Se requiere un cliente inicializado. Para obtener más información, consulte Initialize a Tablestore client.

Descripción del método

public function describeTable(array $request)

Descripción del parámetro $request

table_name (obligatorio) string: El nombre de la tabla.

Código de ejemplo

A continuación se muestra un código de ejemplo que demuestra cómo consultar información detallada de la tabla 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.';
}