All Products
Search
Document Center

Tablestore:Use Tablestore

最終更新日:Oct 30, 2024

You can access Tablestore by using the Tablestore console, Tablestore CLI, or Tablestore SDKs. This topic describes how to use the Wide Column model and the TimeSeries model in the Tablestore console or Tablestore CLI.

Background information

Before you use Tablestore, you must learn about Tablestore, such as the product overview and basic concepts of Tablestore. Then, you can determine the data storage model and instance type based on your business scenarios.

Tablestore provides three data storage models: the Wide Column model, the TimeSeries model, and the Timeline model. You can select a model based on your business requirements. Different models support different features. For more information, see Functions and features.

Model

Description

Wide Column model

This model is similar to the Google Cloud Bigtable and HBase models, and can be used in various scenarios such as metadata and big data storage. The Wide Column model supports features such as max versions, TTL, auto-increment primary key column, conditional update, local transaction, atomic counter, and filter. For more information, see Overview.

TimeSeries model

The TimeSeries model is designed based on the characteristics of time series data. This model is suitable for scenarios, such as IoT device monitoring, and can be used to store data that is collected by devices and the monitoring data of machines. The TimeSeries model supports automatic indexing of time series metadata and time series query based on various composite conditions. For more information, see Overview.

Timeline model

This model is designed to store message data and is suitable for storing message data that is generated from IM applications and feed streams. This model can meet the requirements of messaging processes, such as message order preservation, storage of large numbers of messages, and real-time synchronization. This model also supports full-text search and Boolean query. For more information, see Overview.

We recommend that you determine the instance type based on your business requirements on read and write performance and costs. Tablestore supports the following instance types: high-performance instance and capacity instance. For more information, see Instance types.

  • High-performance instances are suitable for scenarios that require high read and write performance and high concurrency, such as gaming, financial risk control, social networking applications, and recommendation systems.

  • Capacity instances are suitable for business that is cost-sensitive but does not have high requirements for read performance, such as business that involves log monitoring data, Internet of Vehicles (IoV) data, device data, time series data, logistics data, and public opinion monitoring data.

Preparations

Obtain the logon information of the Alibaba Cloud account or (RAM user that is used to log on to Tablestore.

If you have not created an Alibaba Cloud account, create one on the Alibaba Cloud official website.

To use Tablestore as a RAM user, you must create a RAM user by using your Alibaba Cloud account and grant the RAM user the permissions to access Tablestore. For more information, see Use a RAM policy to grant permissions to a RAM user.

Warning

If the AccessKey pair of your Alibaba Cloud account is leaked, your resources are exposed to potential risks. We recommend that you use the AccessKey pair of a RAM user to perform operations. This prevents the AccessKey pair of your Alibaba Cloud account from being leaked.

If you want to use the Tablestore CLI to access Tablestore, you must create an AccessKey pair for your Alibaba Cloud account or the RAM user. For more information, see Obtain an AccessKey pair.

Use the Wide Column model

You can use the Wide Column model in the Tablestore console or Tablestore CLI. For more information, see Use the Wide Column model in the Tablestore console and Use the Wide Column model in the Tablestore CLI.

Workflow of using the Wide Column model in the Tablestore console

image

The following table describes the main steps in the workflow.

Step

Operation

Description

1

Activate Tablestore

Before you use Tablestore features, you must activate Tablestore. You need to activate Tablestore only once. You are not charged when you activate Tablestore.

If Tablestore is activated, skip this step.

2

Create a Tablestore instance

Create an instance in a region based on the selected instance type. For more information about the supported regions of Tablestore, see Regions.

3

Create a data table

Create a data table to store business-related data. When you create the data table, you can configure the following features based on your business requirements:

  • If you want to use attribute columns to query data, you can create secondary indexes to accelerate queries.

  • You can enable data at rest encryption (DARE) by specifying data encryption settings for the data table.

  • In system design scenarios that require an auto-increment primary key column, such as item IDs on e-commerce websites, user IDs on large websites, post IDs in forums, and message IDs in chat tools, you can specify an auto-increment primary key column when you create a data table.

4

Read and write data

You can write, update, read, and delete data in the data table.

5

Use SQL statements to query data

Important

You can use the SQL query feature only in regions that support SQL queries. For more information about the regions that support SQL queries, see Features supported in specific regions.

The SQL query feature is compatible with MySQL query syntax and supports table creation by using Data Definition Language (DDL) statements. For existing data tables, you can execute the CREATE TABLE statement to create mapping tables for the existing data tables. Then, you can use SQL statements to access the data in the existing data tables. For more information, see SQL query.

Workflow of using the Wide Column model in the Tablestore CLI

image

The following table describes the main steps in the workflow.

Step

Operation

Description

1

Download and start the Tablestore CLI

Download the Tablestore CLI based on your operating system. Then, start the Tablestore CLI.

2

Activate Tablestore

Before you use Tablestore features, you must activate Tablestore. You need to activate Tablestore only once. You are not charged when you activate Tablestore.

If Tablestore is activated, skip this step.

3

Create a Tablestore instance

Create a high-performance instance in a region that supports high-performance instances. For more information about the supported regions of Tablestore, see Regions.

Important

When you use Tablestore in the Tablestore CLI, you can create only high-performance instances. For more information about the supported instance types in different regions, see Instance types that are supported in each region.

4

Configure access information

Specify the AccessKey pair of your Alibaba Cloud account or RAM user to access the created Tablestore instance.

5

Create a data table and use the table

Create a data table to store business-related data. After you create a data table, you can perform data operations on the table.

6

Perform data operations

You can insert, update, read, and delete a row of data, and import or export data based on your business requirements. For more information, see Operations on data.

7

Use SQL statements to query data

Important

You can use the SQL query feature only in regions that support SQL queries. For more information about the regions that support SQL queries, see Features supported in specific regions.

The SQL query feature is compatible with MySQL query syntax and supports table creation by using Data Definition Language (DDL) statements. For existing data tables, you can execute the CREATE TABLE statement to create mapping tables for the existing data tables. Then, you can use SQL statements to access the data in the existing data tables. For more information, see SQL query.

Use the TimeSeries model

Important

You can use this feature only in regions that support the TimeSeries model. For more information about the regions that support the TimeSeries model, see Features supported in specific regions.

You can use the TimeSeries model in the Tablestore console or Tablestore CLI. For more information, see Use the TimeSeries model in the Tablestore console and Use the TimeSeries model in the Tablestore CLI.

Workflow of using the TimeSeries model in the Tablestore console

image

The following table describes the main steps in the workflow.

Step

Operation

Description

1

Activate Tablestore

Before you use Tablestore features, you must activate Tablestore. You need to activate Tablestore only once. You are not charged when you activate Tablestore.

If Tablestore is activated, skip this step.

2

Create an instance for the TimeSeries model

Create an instance in a region that supports the TimeSeries model based on the selected instance type. For more information about the supported regions of Tablestore, see Regions.

Important

If the Create Instance for TimeSeries Model button is not available in a region that supports the TimeSeries model, click Create Instance. For more information, see Create an instance.

3

Create a time series table

Create a time series table to store business-related data. When you create a time series table, you can specify the validity period of data in the time series table.

You can also create a test table to experience the TimeSeries module with ease.

4

Write time series data

Write time series data to the time series table. Time series data consists of metadata and data. If you do not create metadata before you write the time series data, the system automatically extracts the metadata from the written data.

5

Query time series data

If you are unsure about the information about the time series that you want to query, such as the metric name and data source, you can specify multiple conditions to retrieve time series.

After you specify the time series, you can query time series data within a specific time range. The query result can be displayed in a list or graph.

6

Use SQL statements to query data

Important

You can use the SQL query feature only in regions that support SQL queries. For more information about the regions that support SQL queries, see Features supported in specific regions.

SQL queries are compatible with the query syntax of MySQL. After you create a time series table and create a mapping table for the time series table in SQL, you can execute SQL statements to access data in the table.

You can create three types of mapping tables for a time series table to query data by executing the corresponding SQL statement. For more information, see Use SQL to query time series data.

Workflow of using the TimeSeries model in the Tablestore CLI

image

The following table describes the main steps in the workflow.

Step

Operation

Description

1

Download and start the Tablestore CLI

Download the Tablestore CLI based on your operating system. Then, start the Tablestore CLI.

2

Activate Tablestore

Before you use Tablestore features, you must activate Tablestore. You need to activate Tablestore only once. You are not charged when you activate Tablestore.

If Tablestore is activated, skip this step.

3

Create a Tablestore instance for the TimeSeries model

Create an instance in a region that supports the TimeSeries model based on the selected instance type. For more information about the supported regions of Tablestore, see Regions.

Important

If the Create Instance for TimeSeries Model button is not available in a region that supports the TimeSeries model, click Create Instance. For more information, see Create an instance.

4

Configure access information

Specify the AccessKey pair of your Alibaba Cloud account or RAM user to access the created Tablestore instance.

5

Create a time series table and use the table

Create a time series table to store business-related data. When you create a time series table, you can specify the validity period of data in the time series table.

After you create a time series table, you can perform operations on the table or data in the table.

6

Perform data operations

Perform operations on data based on your business requirements. You can write time series data, import time series data, query time series data, retrieve a time series, scan a time series, and update a time series.

7

Use SQL statements to query data

Important

You can use the SQL query feature only in regions that support SQL queries. For more information about the regions that support SQL queries, see Features supported in specific regions.

SQL queries are compatible with the query syntax of MySQL. After you create a time series table and create a mapping table for the time series table in SQL, you can execute SQL statements to access data in the table.

You can create three types of mapping tables for a time series table to query data by executing the corresponding SQL statement. For more information, see Use SQL to query time series data.