All Products
Search
Document Center

Tablestore:Update the configurations of a table

Last Updated:Jun 20, 2025

This topic describes how to update table configurations using Tablestore SDK for Node.js.

Prerequisites

Initialize a Tablestore client

Method description

updateTable: function describeTable(params, callback) 

params parameter description

  • tableName (required) string: the name of the data table.

  • tableOptions (required) object: the table configuration information, which includes the following parameters.

    Name

    Type

    Description

    timeToLive (optional)

    number

    The time to live (TTL) of data in the time series table. Unit: seconds.

    • If you set the value to -1, the data never expires. Otherwise, the minimum value is 86400 (one day). Data that exceeds the TTL is automatically purged.

    • If you want to use the search index or secondary index feature, you must set the TTL to -1 or set the allowUpdate parameter to false.

    maxVersions (optional)

    number

    The maximum number of versions.

    • If you want to use the search index or secondary index feature, you must set the maximum number of versions to 1.

    maxTimeDeviation (optional)

    number

    The maximum version offset. Unit: seconds.

    • The difference between the timestamp of the written data and the current system time must be within the maximum version offset range. Otherwise, the data write fails.

    • The valid version range for attribute column data is [max(data write time - maximum version offset, data write time - TTL), data write time + maximum version offset).

    allowUpdate (optional)

    boolean

    Specifies whether to allow updates.

    • If you set the value to false, you cannot update data by using the updateRow() method.

  • streamSpecification (optional) object: the Stream configuration information, which includes the following parameters.

    Name

    Type

    Description

    enableStream (optional)

    boolean

    Specifies whether to enable Stream. Default value: false.

    expirationTime (optional)

    number

    The expiration time of the Stream, which indicates the duration of incremental log retention. Unit: hours. Maximum value: 168 (seven days).

    • If enableStream is set to true, you must set expirationTime.

  • reservedThroughput (optional) object: reserved read and write throughput, in capacity units (CUs). Only high-performance instances in CU mode can be set to non-zero values.

Note
  • When you call the updateTable() method, you must set tableOptions.

  • When you set tableOptions, you must set at least one of the following parameters: timeToLive, maxVersions, maxTimeDeviation, or allowUpdate.

Sample code

The following sample code demonstrates how to modify the configurations of the test_table table.

var params = {
    tableName: 'test_table',
    tableOptions: {
        // Set the TTL to 86400 seconds
        timeToLive: 86400,
        // Set the maximum number of versions
        maxVersions: 3,
        // Set the maximum version offset to 86400 seconds
        maxTimeDeviation: 86400,
        // Specify whether to allow updates
        allowUpdate: false
    },
    // Set the reserved read throughput to 0 CUs and the reserved write throughput to 0 CUs (Only high-performance instances in CU mode support setting non-zero values for reserved read and write throughput)
    reservedThroughput: {
        capacityUnit: {
            read: 0,
            write: 0
        }
    },
    // Enable Stream and set the Stream expiration time to 7 days
    streamSpecification: {
        enableStream: true,
        expirationTime: 168
    }
};

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