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, billing mode, 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 Features.
Model | Description |
Wide Column | This model is similar to the Google Cloud Bigtable and HBase models, and can be used in multiple 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 Wide Column model. |
TimeSeries | This model is designed to store time series data generated from multiple scenarios such as IoT device monitoring, device data collection, and machine monitoring. The TimeSeries model supports automatic indexing of time series metadata and time series query by various composite conditions. For more information, see TimeSeries model. |
Timeline | This model is designed to store message data and is suitable for storing message data generated from IM applications and feed streams. This model can meet the specific 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 Timeline model. |
After you determine the data storage model, determine the billing mode based on your business needs. Tablestore supports two billing modes: reserved mode and pay-as-you-go mode.
If you want to use Tablestore for service tests in a test environment, we recommend that you create an instance billed in pay-as-you-go mode.
If you want to use Tablestore in actual business scenarios, we recommend that you create an instance billed in a mode that can adapt to your business requirements. For more information, see Billing overview.
After you determine the billing mode, you can determine the instance type based on your business requirements for the read and write performance and costs. Tablestore supports two instance types: high-performance instance and capacity instance. For more information, see Instance.
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 Resource Access Management (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.
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 and Tablestore CLI. For more information, see Use the Wide Column model in the Tablestore console and Manage the Wide Column model in the Tablestore CLI.
Workflow of using the Wide Column model in the Tablestore console
The following table describes the main steps in the workflow.
Step | Operation | Description |
1 | Before you use Tablestore features, you must activate Tablestore. You need to only activate Tablestore once. You are not charged when you activate Tablestore. If Tablestore is activated, skip this step. | |
2 | Create an instance in a region based on the selected billing mode and instance type. For more information about the supported regions of Tablestore, see Region. | |
3 | 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:
| |
4 | You can write, update, read, and delete data in the data table. | |
5 | 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 the Features supported in specific regions section of the "Features and regions" topic. 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. |
Workflow of using the Wide Column model in the Tablestore CLI
The following table describes the main steps in the workflow.
Step | Operation | Description |
1 | Download the Tablestore CLI based on your operating system. Then, start the Tablestore CLI. | |
2 | Before you use Tablestore features, you must activate Tablestore. You need to only activate Tablestore once. You are not charged when you activate Tablestore. If Tablestore is activated, skip this step. | |
3 | Create a high-performance instance in pay-as-you-go mode in a region that supports high-performance instances. For more information about the supported regions of Tablestore, see Region. Important When you use Tablestore in the Tablestore CLI, you can create only high-performance instances in pay-as-you-go mode. For more information about the supported instance types in different regions, see the Instance types that are supported in each region section of the "Instance" topic. | |
4 | Grant access permissions on the created Tablestore instance by using the AccessKey pair of your account. | |
5 | Create a data table to store business-related data. After you create a data table, you can perform data operations on the table. | |
6 | You can insert, update, read, and delete a row of data, and import or export data based on your business requirements. | |
7 | 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 the Features supported in specific regions section of the "Features and regions" topic. 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. |
Use the TimeSeries model
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 the Features supported in specific regions section of the "Features and regions" topic.
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
The following table describes the main steps in the workflow.
Step | Operation | Description |
1 | Before you use Tablestore features, you must activate Tablestore. You need to only activate Tablestore once. You are not charged when you activate Tablestore. If Tablestore is activated, skip this step. | |
2 | Create an instance in a region that supports the TimeSeries model based on the selected billing mode and instance type. For more information about the supported regions of Tablestore, see Region. | |
3 | 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 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 | If you do not know 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 the time series that meet the specified conditions. | |
6 | Query the time series data that meets the specified conditions in a specified time series. The query result can be displayed in a list or graph. | |
7 | 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 the Features supported in specific regions section of the "Features and regions" topic. The SQL query syntax supported by Tablestore is 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
The following table describes the main steps in the workflow.
Step | Operation | Description |
1 | Download the Tablestore CLI based on your operating system. Then, start the Tablestore CLI. | |
2 | Before you use Tablestore features, you must activate Tablestore. You need to only activate Tablestore once. You are not charged when you activate Tablestore. If Tablestore is activated, skip this step. | |
3 | Create an instance in a region that supports the TimeSeries model based on the selected billing mode and instance type. For more information about the supported regions of Tablestore, see Region. | |
4 | Grant access permissions on the created Tablestore instance by using the AccessKey pair of your account. | |
5 | 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 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 | 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 the Features supported in specific regions section of the "Features and regions" topic. The SQL query syntax supported by Tablestore is 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. |