All Products
Search
Document Center

Tablestore:Query information of a table

Last Updated:Jun 24, 2025

This topic describes how to query information of a table by using Tablestore SDK for Node.js.

Prerequisites

A client is initialized. For more information, see Initialize a Tablestore client.

Method description

describeTable: function describeTable(params, callback)

params parameter description

tableName (required) string: The name of the table.

Sample code

The following sample code demonstrates how to query information of the test_table 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)");
    });
});