Updated on 2025-08-28 GMT+08:00

Creating a Table

Scenarios

You will create a table in a store and create indexes for it.

Prerequisites

The store where you want to create a table has been created.

Notes and Constraints

  • Up to 100 tables can be created in a store.
  • A table must belong to a store.
  • You can only define one shard key and one sort key for a single table.
  • A table name must be 3 to 52 characters long and unique store-wide. Numbers (0–9), letters (a–z and A–Z), hyphens (-), and underscores (_) are allowed.
  • Table names are case-sensitive. Suppose you have a table named exampletable in a store. You can create another table named ExampleTable in the store successfully.

Procedure

  1. Log in to the KVS console.
  2. In the navigation pane, choose Stores.
  3. Search for and select a store where you want to create a table and click Create Table in the Operation column. Or click the store name to go to its details page and click Create Table.
  4. In the Basic Configuration area, select a billing mode. For details about the billing modes, see Table 1.

    Figure 1 Basic Configuration page

    Table 1 Basic configuration parameters

    Type

    Parameter

    Description

    Basic Configuration

    Pay-per-Use

    Post payment. Choose this mode if your service traffic is unpredictable or fluctuates a lot.

    Provisioned

    Post payment. Choose this mode if your service traffic is stable or predictable.

  5. Configure table parameters as instructed.

    Figure 2 Table Details page
    Table 2 Table parameters

    Type

    Parameter

    Description

    Table Details

    Name

    Mandatory

    The name of a table. A table name must be 3 to 52 characters long and unique store-wide. Numbers (0–9), letters (a–z and A–Z), hyphens (-), and underscores (_) are allowed.

    Shard Key

    Mandatory

    A shard key must be 1 to 63 characters long and cannot start with an underscore (_). Numbers (0–9), letters (a–z and A–Z), hyphens (-), and underscores (_) are allowed.

    Sort Key

    Optional

    A sort key must be 1 to 63 characters long and cannot start with an underscore (_). Numbers (0–9), letters (a–z and A–Z), hyphens (-), and underscores (_) are allowed.

  6. (Optional) This step is only required for the provisioned billing mode. In the Provisioned Throughput area, configure parameters shown in Table 3.

    The provisioned read/write throughput of a table is determined by the average KV item size, the number of KV items read/written per second, average size of local secondary index items, and the number of local secondary index items read/written per second.

    You can use the calculator to estimate the read and write throughputs by clicking Throughput Calculator and configure parameters shown in Figure 4. For details about the parameters, see Table 4. After the parameters are configured, click OK. The calculated values are automatically synchronized to Read Throughput and Write Throughput as shown in Figure 3.

    Figure 3 Provisioned Throughput page

    Figure 4 Throughput Calculator page

    Table 3 Provisioned throughput parameters

    Type

    Parameter

    Description

    Provisioned Throughput

    Read Throughput

    • Value range: 1 to 50000 (unit: RCU)
      NOTE:

      Up to 100,000 RCUs can be provisioned for each user in a region.

    • Read throughput = ROUNDUP(Average KV item size in KB/4) × KV items read per second + ROUNDUP(Average size of local secondary index items in KB/4) × Local secondary index items read per second

    Write Throughput

    • Value range: 1 to 50000 (unit: WCU)
      NOTE:

      Up to 100,000 WCUs can be provisioned for each user in a region.

    • Write throughput = ROUNDUP(Average KV item size in KB) × KV items written per second + ROUNDUP(Average size of local secondary index items in KB) × Local secondary index items written per second
    Table 4 Throughput Calculator parameters

    Parameter

    Example Value

    Description

    Average KV Item Size

    100

    • Required
    • Enter the provisioned average KV size, in KB.

    KV Items Read per Second

    10

    • Required
    • Enter the number of KV items to be read per second.

    KV Items Written per Second

    10

    • Required
    • Enter the number of KV items to be written per second.

    Average Size of Local Secondary Index Items

    100

    • Required
    • Enter the provisioned average size of local secondary index items, in KB.

    Local Secondary Index Items Read per Second

    10

    • Required
    • Enter the number of local secondary index items to be read per second.

    Local Secondary Index Items Written per Second

    10

    • Required
    • Enter the number of local secondary index items to be written per second.

    Read Throughput

    500

    • The value is automatically calculated. The unit is RCU.
    • Read throughput = ROUNDUP(Average KV item size in KB/4) × KV items read per second + ROUNDUP(Average size of local secondary index items in KB/4) × Local secondary index items read per second

    Write Throughput

    2000

    • The value is automatically calculated. The unit is WCU.
    • Write throughput = ROUNDUP(Average KV item size in KB) × KV items written per second + ROUNDUP(Average size of local secondary index items in KB) × Local secondary index items written per second

  7. In the Secondary Index area, create secondary indexes. KVS allows you to create local and global secondary indexes.

    1. Click Create Local Secondary Index and configure parameters as instructed in Table 5. Confirm the configuration and click OK.
      Figure 5 Local Secondary Indexes

      Table 5 Local secondary index parameters

      Type

      Parameter

      Description

      Create Local Secondary Index

      Name

      Mandatory

      The name of a local secondary index. It must be 1 to 255 characters long. Numbers (0–9), letters (a–z and A–Z), hyphens (-), underscores (_), and periods (.) are allowed. An index name cannot be XPriIndex.

      Sort Key

      Mandatory

      A sort key must be 1 to 63 characters long and cannot start with an underscore (_). Numbers (0–9), letters (a–z and A–Z), hyphens (-), and underscores (_) are allowed.

      Abstract Field

      Optional

      An abstract field in the local secondary index. You can create multiple abstract fields in an index. An abstract field must be 1 to 63 characters long and cannot start with an underscore (_). Numbers (0–9), letters (a–z and A–Z), hyphens (-), and underscores (_) are allowed.

    2. Click Create Global Secondary Index and configure parameters as instructed in Table 6. Confirm the configuration and click OK.
      Figure 6 Global Secondary Indexes

      Table 6 Global secondary index parameters

      Type

      Parameter

      Description

      Create Global Secondary Index

      Name

      Mandatory

      The name of a global secondary index. It must be 1 to 255 characters long. Numbers (0–9), letters (a–z and A–Z), hyphens (-), underscores (_), and periods (.) are allowed. An index name cannot be XPriIndex.

      Shard Key

      Mandatory

      A shard key must be 1 to 63 characters long and cannot start with an underscore (_). Numbers (0–9), letters (a–z and A–Z), hyphens (-), and underscores (_) are allowed.

      Sort Key

      Optional

      A sort key must be 1 to 63 characters long and cannot start with an underscore (_). Numbers (0–9), letters (a–z and A–Z), hyphens (-), and underscores (_) are allowed.

      Read Throughput

      Value range: 1 to 50000 (unit: RCU) This field is only valid in the provisioned billing mode.

      Write Throughput

      Value range: 1 to 50000 (unit: WCU) This field is only valid in the provisioned billing mode.

      Abstract Field

      Optional

      An abstract field in the global secondary index. You can create multiple abstract fields in an index. An abstract field must be 1 to 63 characters long and cannot start with an underscore (_). Numbers (0–9), letters (a–z and A–Z), hyphens (-), and underscores (_) are allowed.

  8. Confirm the configuration and click OK.