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 de uma tabela com o Tablestore SDK for Node.js.

Pré-requisitos

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

Descrição do método

describeTable: function describeTable(params, callback)

Descrição do parâmetro params

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

Código de exemplo

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

var params = {
    tableName: 'test_table'
};

client.describeTable(params, function (err, data) {
    if (err) {
        console.error('error:', err);
        return;
    }

    // Query the schema information of a table.
    var tableMeta = data.tableMeta;
    console.log('* Table name:', tableMeta.tableName);
    console.log('* Primary key information (primary key type 1:INTEGER,2:STRING,3:BINARY)');
    tableMeta.primaryKey.forEach(function (primaryKey) {
        console.log(primaryKey.name, ':', primaryKey.type);
    });
    console.log("* Predefined column information (predefined column type 1:INTEGER,2:DOUBLE,3:BOOLEAN,4:STRING)");
    tableMeta.definedColumn.forEach(function (definedColumn) {
        console.log(definedColumn.name, ':', definedColumn.type);
    });

    // Obtain table configuration information.
    var tableOptions = data.tableOptions;
    console.log("* Table configuration information");
    console.log("Max versions:", tableOptions.maxVersions);
    console.log("Time to live:", tableOptions.timeToLive);
    console.log("Max version offset:", tableOptions.deviationCellVersionInSec.toNumber());
    console.log("Allow update:", tableOptions.allowUpdate);

    // Obtain table Stream information.
    var streamDetails = data.streamDetails
    console.log("* Whether to enable Stream:", streamDetails.enableStream);
    if (streamDetails.enableStream) {
        console.log("Stream expiration time:", streamDetails.expirationTime);
    }

    // Obtain reserved read/write throughput of the table.
    var reservedThroughputDetails = data.reservedThroughputDetails
    console.log("* Reserved read/write throughput");
    console.log("Reserved read throughput:", reservedThroughputDetails.capacityUnit.read);
    console.log("Reserved write throughput:", reservedThroughputDetails.capacityUnit.write);

    // Obtain secondary index information.
    data.indexMetas.forEach(function (indexMeta) {
        console.log("* Secondary index name:", indexMeta.name);
        console.log("Primary key columns:", indexMeta.primaryKey);
        console.log("Predefined columns:", indexMeta.definedColumn);
        console.log("Secondary index type:", indexMeta.indexType, "(0:IT_GLOBAL_INDEX,1:IT_LOCAL_INDEX)");
        console.log("Secondary index update mode:", indexMeta.indexUpdateMode, "(0:IUM_ASYNC_INDEX,1:IUM_SYNC_INDEX)");
    });
});