Todos os produtos
Search
Central de documentação

Tablestore:Consultar informações de uma tabela de dados

Última atualização: Jul 03, 2026

Use describeTable no Tablestore SDK for Java para obter o esquema, a configuração e os metadados de uma tabela de dados.

Pré-requisitos

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

Método

public DescribeTableResponse describeTable(DescribeTableRequest request) throws TableStoreException, ClientException

Parâmetros de DescribeTableRequest

  • tableName (obrigatório) String: nome da tabela de dados.

Código de exemplo

O exemplo a seguir obtém informações da tabela de dados test_table, incluindo esquema, configuração, definições de Stream, configurações de criptografia, throughput reservado e índices secundários.

public static void describeTableExample(SyncClient client) {
    DescribeTableRequest request = new DescribeTableRequest("test_table");
    DescribeTableResponse response = client.describeTable(request);

    // Query the schema information of the data table.
    TableMeta tableMeta = response.getTableMeta();
    System.out.println("* Data table name: " + tableMeta.getTableName());
    System.out.println("* Primary key information");
    for(PrimaryKeySchema primaryKeySchema : tableMeta.getPrimaryKeyList()) {
        System.out.println(primaryKeySchema);
    }
    System.out.println("* Predefined column information");
    for(DefinedColumnSchema definedColumnSchema : tableMeta.getDefinedColumnsList()) {
        System.out.println(definedColumnSchema);
    }

    // Query the configuration information of the data table.
    TableOptions tableOptions = response.getTableOptions();
    System.out.println("* Table configuration information");
    System.out.println("Max versions: " + tableOptions.getMaxVersions());
    System.out.println("Time to live: " + tableOptions.getTimeToLive());
    System.out.println("Max version offset: " + tableOptions.getMaxTimeDeviation());
    System.out.println("Whether to allow updates: " + tableOptions.getAllowUpdate());

    // Query the Stream information of the data table.
    StreamDetails streamDetails = response.getStreamDetails();
    System.out.println("* Whether to enable Stream: " + streamDetails.isEnableStream());
    if(streamDetails.isEnableStream())
        System.out.println("Stream validity period: " + streamDetails.getExpirationTime());

    // Query the encryption settings of the data table.
    SSEDetails sseDetails = response.getSseDetails();
    System.out.println("* Whether to enable encryption for the data table: " + sseDetails.isEnable());
    if(sseDetails.isEnable())
        System.out.println("Encryption method: " + sseDetails.getKeyType());
        
    // Query the reserved read/write throughput of the data table.
    ReservedThroughputDetails reservedThroughputDetails = response.getReservedThroughputDetails();
    System.out.println("* Reserved read/write throughput");
    System.out.println("Reserved read throughput: " + reservedThroughputDetails.getCapacityUnit().getReadCapacityUnit());
    System.out.println("Reserved write throughput: " + reservedThroughputDetails.getCapacityUnit().getWriteCapacityUnit());

    // Query information of the secondary index.
    for(IndexMeta indexMeta : response.getIndexMeta()) {
        System.out.println("* Secondary index name: " + indexMeta.getIndexName());
        System.out.println("Primary key columns: " + indexMeta.getPrimaryKeyList().toString());
        System.out.println("Predefined columns: " + indexMeta.getDefinedColumnsList().toString());
        System.out.println("Secondary index type: " + indexMeta.getIndexType());
        System.out.println("Secondary index update mode: " + indexMeta.getIndexUpdateMode());
    }
}

Referências

Consultar informações de uma tabela de séries temporais