All Products
Search
Document Center

Tablestore:Operations on tables

Last Updated:Nov 21, 2023

This topic describes the operations that you can perform on tables by using Tablestore SDK for Java.

When you use Tablestore, you must create tables for data storage. In most cases, you do not need to configure secondary indexes for your tables. You can create tables that have the following features based on your business requirements:

  • If you want to use a secondary index to improve data query efficiency, configure a secondary index when you create a table. For more information, see Create a data table.

    The secondary index feature allows you to create one or more index tables for a table. Then, you can query data based on the primary key columns of the index tables instead of the table.

  • If you want to perform atomic operations to read or write one or more rows of data, enable the local transaction feature when you create a table. For more information, see Create a data table.

  • If you want to use an auto-increment primary key column for data such as product IDs, user IDs, post IDs, and message IDs, configure an auto-increment primary key column when you create a table. For more information, see Configure an auto-increment primary key column.

  • If you want to encrypt a table when the table is saved to a disk, configure table encryption when you create a table. For more information, see Create an encrypted table.

After you create tables, you can perform the following operations on the tables based on your business requirements.

Operation

Description

Update table information

Updates the configurations of a table, such as the time to live (TTL) and max versions of data.

Query the description of a table

Queries the configurations of a table.

Query the names of tables

Queries the names of all tables in an instance.

Add or remove predefined columns

Adds predefined columns to or removes predefined columns from a table. When you create a secondary index for a table, you can set the predefined columns of the table as the index columns or attribute columns of the secondary index.

Delete a table

Deletes a table.

You can also use the following features when you perform operations on data in tables based on your business requirements.

Feature

Description

Scenario

Configure conditional update

If you use conditional update, data in a table can be updated only when the conditions are met. Otherwise, the update fails and an error message is returned.

This feature is suitable for updating data in high-concurrency scenarios.

Configure local transaction

After you enable local transaction for a table, you can create a local transaction based on a partition key value. After you read or write data within a local transaction, you can commit or abort the local transaction.

This feature is suitable for performing atomic operations to read or write one or more rows of data.

Configure atomic counter

Atomic counters allow you to implement an atomic counter on a column.

This feature is suitable for obtaining statistical data for online applications, such as the number of page views (PVs) on various posts.

Configure a filter

After you configure a filter, query results are filtered on the server side based on the filter conditions. Only rows of data that match the filter conditions are returned.

This feature is suitable for querying data that meets specific conditions.

Split data into shards of a specific size

You can split data in a table into logical shards whose sizes are approximately the specified value. The information about the split points among the shards and the machines on which the shards reside is returned.

This feature is suitable for implementing concurrency plans on compute engines.