CreateTable

更新时间: 2026-01-28 00:23:56

You can call the CreateTable operation to create a data table with the specified table schema.

Notes

  • A newly created table is not immediately available for read and write operations. You must wait for about one minute after the table is created before you can perform these operations.

  • You can create a maximum of 64 tables in a single instance. To increase this limit, submit a ticket.

Request message structure

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. This includes the following configuration items:

Important

After a table is created, its schema cannot be modified.

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

  • primary_key: The primary key. The primary key must contain one to four primary key columns (ColumnSchema). The name of each primary key column must follow the naming conventions and data type rules. The type can only be STRING, INTEGER, or BINARY. For more information about naming conventions and data types, see Naming conventions and data types.

  • defined_Columns: The predefined columns. To use a secondary index, add predefined columns to the data table. Define non-primary key columns and their types in advance to use them as attribute columns or index columns for an index table. You can also add predefined columns after creating the table. For more information, see How to use predefined columns.

reserved_throughput

ReservedThroughput

Yes

The reserved read throughput and reserved write throughput for the data table. The reserved read throughput and the reserved write throughput cannot exceed 100,000 each. The unit is CU.

Use the UpdateTable operation to change the reserved read and write throughput.

table_options

TableOptions

No

Includes settings such as TimeToLive and max versions.

partitions

PartitionRange

No

The partition range of the data table.

stream_spec

StreamSpecification

No

Specifies whether to enable stream properties.

sse_spec

SSESpecification

No

The encryption configuration for 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. The default value is false.

To perform atomic operations for single-row or multi-row reads and writes, enable the local transaction feature for the data table.

Response message structure

message CreateTableResponse {
}

Use an SDK

You can use an SDK in one of the following languages to create a data table.

上一篇: Operations on data tables 下一篇: ListTable
阿里云首页 表格存储 相关技术圈