All Products
Search
Document Center

Tablestore:Update the configurations of a table

Last Updated:Nov 14, 2024

This topic uses parameters and sample code to describe how to use Tablestore SDK for Node.js to update the configurations of a table. You can update the time to live (TTL), max versions, max version offset, and Stream configuration of a data table. You can also update the reserved read and write throughput of a data table in a high-performance instance.

Prerequisites

API operation

/**
 * Update the configurations of a data table by using tableOptions, reservedThroughput, or streamSpecification. 
 */
updateTable(params, callback)

Parameters

For more information, see Parameters.

Sample code

Update the configurations of a data table

The following sample code provides an example on how to update the configurations of a data table.

var params = {
    // Specify the name of the data table. 
    tableName: '<TABLE_NAME>',
    tableOptions: {
        // Specify the TTL of data in the data table. A value of -1 specifies that data in the data table never expires. 
        timeToLive: -1,
        // Specify the maximum number of versions that can be retained for data in each attribute column of the data table. In this example, up to five versions of data can be retained for each attribute column. 
        maxVersions: 5,
        // Specify the maximum difference between the current system time and the timestamp of the written data. In this example, the maximum difference is set to 86,400 seconds (one day). 
        maxTimeDeviation: 86400,
        // Specify that the UpdateRow operation on the data table is allowed. 
        allowUpdate: true
    },
    // streamSpecification: {
    //     // Enable the Stream feature. 
    //     enableStream: true,
    //     // Set the validity period of streams to 24 hours. 
    //     expirationTime: 24
    // }
  };
  
client.updateTable(params, function (err, data) {
    if (err) {
        console.log('error:', err);
        return;
    }
    console.log('success:', data);
});

Update the reserved throughput of a data table in a high-performance instance

The following sample code provides an example on how to update the reserved throughput of a data table in a high-performance instance.

var params = {
    // Specify the name of the data table. 
    tableName: '<TABLE_NAME>',
    tableOptions: {
        // Specify the TTL of data in the data table. A value of -1 specifies that data in the data table never expires. 
        timeToLive: -1,
    },
    // Set the new reserved read throughput to 1 and the new reserved write throughput to 1. You can set the reserved read and write throughput only to 0 for a data table in a capacity instance. 
    reservedThroughput: {
        capacityUnit: {
            read: 1,
            write: 1
        }
    }
};
  
client.updateTable(params, function (err, data) {
    if (err) {
        console.log('error:', err);
        return;
    }
    console.log('success:', data);
});

References

  • For more information about the API operation, see UpdateTable.

  • After you update the configurations of a table, you can perform the following operations: