Tüm Ürünler
Search
Belge Merkezi

Tablestore:Query information of a table

Son Güncelleme:Oct 02, 2026

Bu konuda, Tablestore SDK for Node.js kullanarak tablo bilgilerinin nasıl sorgulanacağı açıklanmaktadır.

Ön koşullar

Bir istemci başlatılmış olmalıdır. Daha fazla bilgi için bkz. Tablestore istemcisini başlatma.

Yöntem açıklaması

describeTable: function describeTable(params, callback)

params parametre açıklaması

tableName (gerekli) string: Tablonun adı.

Örnek kod

Aşağıdaki örnek kod, test_table tablosunun bilgilerinin nasıl sorgulanacağını göstermektedir.

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)");
    });
});