Tous les produits
Search
Centre de documentation

Tablestore:Query information of a table

Dernière mise à jour :Aug 18, 2026

Cette rubrique explique comment interroger les informations détaillées d'une table à l'aide du SDK PHP.

Prérequis

Le client est initialisé. Pour plus d'informations, consultez la section Initialiser un client Tablestore.

Description de la méthode

public function describeTable(array $request)

Description du paramètre $request

table_name (obligatoire) string : nom de la table.

Exemple de code

L'exemple de code suivant montre comment interroger les informations détaillées de la table 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.';
}