The Wide Column model is similar to the data model of Bigtable or HBase and is suitable for various scenarios such as the storage of metadata and big data. A single data table can store petabyte-level data and supports tens of millions of queries per second (QPS). This topic describes how to use the Wide Column model in the Tablestore console.
Prerequisites
Tablestore is activated and an instance is created. For more information, see Activate Tablestore and create an instance.
Procedure
For information about how to get started with the Wide Column model by using the Tablestore CLI, see Get started with the Wide Column model.
Step 1: Create a data table
Create a data table to store business-related data.
For information about sample scenarios and table schemas, see Sample scenarios.
Go to the Instance Management page.
Log on to the Tablestore console.
In the top navigation bar, select a resource group and a region.
On the Overview page, click the name of the instance that you want to manage or click Manage Instance in the Actions column of the instance.
On the Instance Details tab of the Instance Management page, click Create Table.
In the Create Table dialog box, set Table Name to order and configure the primary key of the table.
Click Create.
After a data table is created, you can view the data table on the Tables tab. If the data table that you created is not displayed on the tab, click the
icon to refresh the table list.
Step 2: Read and write data
In the Tables section of the Instance Details tab, click Query in the Actions column of the table that you want to manage. On the Query Data tab, read and write data based on your business requirements.
Insert a single row of data
If you want to insert multiple rows of data, repeat the steps multiple times.
On the Query Data tab, click Insert.
In the Insert dialog box, configure the Primary Key Value parameter for each primary key column. Perform the following operations each time you specify an attribute column: Click Add Column and configure the Name, Type, and Value parameters.
Click OK.
Update a single row of data
You can update the data of an existing row. In this example, the after-sales status of an order is updated and a new attribute column named comments is added. The comments attribute column is of the String type.
On the Query Data tab, select the row of data that you want to update. Click Update.
In the Update dialog box, perform the following operations based on your business requirements.
Add an attribute column: Click Add Column, set Name to comments, select STRING from the Type drop-down list, and specify a value for the Value parameter.
Update data in an attribute column: Select Update from the Actions drop-down list and modify the value of the order_status attribute column.
Click OK.
Read data
You can read a single row of data or data whose primary key value is within a specific range in the Tablestore console based on your business requirements.
You can execute SQL statements to query and analyze data in the table. For more information, see SQL query.
Read data whose primary key value is within a specific range
On the Query Data tab, click Search.
In the Search dialog box, set Mode to Range Search.
By default, the system returns all columns. To return specific attribute columns, turn off All Columns and enter the names of the attribute columns that you want to return. Separate multiple attribute column names with commas (,).
Specify the Start Primary Key Column and End Primary Key Column parameters for each primary key column and retain the default settings for other parameters.
NoteIf you set Mode to Range Search, the range that is specified by the start value and the end value in the right primary key column takes effect only when the start value and the end value are the same within each leftmost primary key column. If the start value and the end value in a leftmost primary key column are different, the range that is specified by the start value and the end value in the right primary key column does not take effect.
The range is a left-open, right-closed interval.
Click OK.
The system displays all rows that meet the query conditions. If no rows meet the query conditions, the response is empty.
Read a single row of data
On the Query Data tab, click Search.
In the Search dialog box, set Mode to Get Row.
By default, the system returns all columns. To return specific attribute columns, turn off All Columns and enter the names of the attribute columns that you want to return. Separate multiple attribute column names with commas (,).
Configure the Primary Key Value parameter for each primary key column of the row whose data you want to query and retain the default settings for other parameters.
The integrity and accuracy of the primary key value affect the query results.
Click OK.
The system displays the row that meets the query conditions. If no row meets the query conditions, the response is empty.
Delete data
The data that you delete cannot be restored. Proceed with caution.
On the Query Data tab, select the row of data that you want to delete. Click Delete.
In the Delete message, click OK.
Sample scenarios
The order system is a very common system that is used in various industries nowadays. For example, it is used by e-commerce platforms to store orders, by banks to store transaction records, and by telecom operators to store bills. In this example, an order table in the order system is used to describe how to create a data table and read and write data in the data table. The name of the order table is order. The following table describes the schema of the table.
Column name | Data type | Description |
order_id (primary key column) | String | The ID of the order. In this example, hashing is performed by using the order ID generation algorithm to prevent hotspot data. |
user_id | String | The ID of the customer. |
sku_id | String | The ID of the product. |
total_price | Double | The total amount of the order. |
order_status | String | The status of the order. |
create_time | String | The time when the order was created. The value is a 64-bit timestamp in milliseconds. |
last_modified | String | The time when the order was last modified. |
FAQ
References
You can use secondary indexes or search indexes to accelerate data queries. For more information, see Secondary index and Search index.