All Products
Search
Document Center

Tablestore:CreateTable

Last Updated:May 07, 2025

Creates a data table based on the specified schema.

Usage notes

  • After you create a data table, you cannot immediately perform read and write operations on the data table. In most cases, you can perform read and write operations on a data table one minute after the data table is created.

  • You can create up to 64 tables in a single instance. If you want to create more tables in a single instance, submit a ticket.

Request syntax

message CreateTableRequest {
    required TableMeta table_meta = 1;
    required ReservedThroughput reserved_throughput = 2; 
    optional TableOptions table_options = 3;
    repeated PartitionRange partitions = 4;
    optional StreamSpecification stream_spec = 5;
    optional SSESpecification sse_spec = 6;
    repeated IndexMeta index_metas = 7;
    optional bool enable_local_txn = 8;
}

Parameter

Type

Required

Description

table_meta

TableMeta

Yes

The schema of the data table. Configure the following parameters:

Important

After you create a data table, you cannot modify the schema of the data table.

  • table_name: the name of the data table. The table name must be unique within the instance.

  • primary_key: the information about the primary key. A primary key can contain one to four primary key columns. The name of each primary key column must comply with the naming conventions, and the data types of the primary key columns must be STRING, INTEGER, or BINARY. For more information about the naming conventions and data types, see Naming conventions and data types.

  • defined_Columns: the information about the predefined columns. If you want to use a secondary index for a data table, you must add predefined columns to the data table when you create the data table. Predefined columns are non-primary key columns that are predefined with specific data types. After you add a predefined column to a data table, you can use the predefined column as an attribute column or index key column of an index table. You can also add predefined columns to a data table after the data table is created. For more information, see How do I use predefined columns?

reserved_throughput

ReservedThroughput

Yes

The reserved read or write throughput of the data table. The reserved read or write throughput of a data table cannot exceed 100,000. Unit: capacity unit (CU).

You can call the UpdateTable operation to change the reserved read or write throughput of a data table.

table_options

TableOptions

No

The table parameters, including time_to_live and max_versions.

partitions

PartitionRange

No

The partition range of the data table.

stream_spec

StreamSpecification

No

Specifies whether to enable Stream-related attributes.

sse_spec

SSESpecification

No

The encryption configurations of the data table.

index_metas

IndexMeta

No

The schema of the index table.

enable_local_txn

bool

No

Specifies whether to enable the local transaction feature for the data table. Default value: false.

To perform atomic operations to read or write one or more rows of data, enable the local transaction feature for the data table.

Response syntax

message CreateTableResponse {
}

Use Tablestore SDKs

You can use the following Tablestore SDKs to create a data table based on the specified schema: