Tüm Ürünler
Search
Belge Merkezi

Tablestore:Query data by executing SQL statements

Son Güncelleme:Oct 02, 2026

Bu konu, Node.js için Tablestore SDK kullanarak SQL ifadeleri çalıştırarak verilerin nasıl sorgulanacağını açıklar.

Önkoşullar

Parametreler


Parametre


Açıklama


query


SQL ifadesi. Bu parametreyi gereken özelliğe göre yapılandırın.

Örnek

Aşağıdaki örnek kod, test_table adlı tablodaki tüm verilerin nasıl sorgulanacağını gösterir:

const client = require('./client');

const params = {
    query: "select * from test_table",
}

client.sqlQuery(params, function (err, resp) {
    if (err) {
        console.log('sqlQuery error:', err.toString());
    } else {
        console.log('sqlQuery success:', resp);
        console.log(resp.sqlRows.rowCount.toFloat64());
        console.log(resp.sqlRows.columnCount);
        console.log(resp.sqlRows.sqlTableMeta)
        for (let i = 0; i < resp.sqlRows.rowCount.toFloat64(); i++) {
            for (let j = 0; j < resp.sqlRows.columnCount; j++) {
                let data = resp.sqlRows.get(i, j);
                // Process data of the Binary type.
                if (resp.sqlRows.sqlTableMeta.schemas[j].typeName === "BINARY") {
                    let int8Array = data.valueArray();
                    console.log(int8Array);
                }
                // Process data of the Long type.
                if (resp.sqlRows.sqlTableMeta.schemas[j].typeName === "LONG") {
                    console.log(data.toFloat64());
                }
                console.log("i:" + i, ", j:" + j + ":" + data);
            }
        }
    }
});

SSS