Version:

Create Table

Creates a new table or collection. If a new table is being created, the type of the table is given by input parameter type_id, which must be the ID of a currently registered type (i.e. one created via Create Type). The table will be created inside a collection if the option collection_name is specified. If that collection does not already exist, it will be created.

To create a new collection, specify the name of the collection in input parameter table_name and set the is_collection option to true; input parameter type_id will be ignored.

A table may optionally be designated to use a replicated distribution scheme, have foreign keys to other tables assigned, be assigned a partitioning scheme, or have a tier strategy assigned.

Input Parameter Description

Name Type Description
table_name string Name of the table to be created. Error for requests with existing table of the same name and type ID may be suppressed by using the no_error_if_exists option. See Tables for naming restrictions.
type_id string ID of a currently registered type. All objects added to the newly created table will be of this type. Ignored if is_collection is true.
options map of string to strings

Optional parameters. The default value is an empty map ( {} ).

Supported Parameters (keys) Parameter Description
no_error_if_exists

If true, prevents an error from occurring if the table already exists and is of the given type. If a table with the same ID but a different type exists, it is still an error. The default value is false. The supported values are:

  • true
  • false
collection_name Name of a collection which is to contain the newly created table. If the collection provided is non-existent, the collection will be automatically created. If empty, then the newly created table will be a top-level table.
is_collection

Indicates whether the new table to be created will be a collection. The default value is false. The supported values are:

  • true
  • false
disallow_homogeneous_tables

No longer supported; value will be ignored. The default value is false. The supported values are:

  • true
  • false
is_replicated

For a table, affects the distribution scheme for the table's data. If true and the given type has no explicit shard key defined, the table will be replicated. If false, the table will be sharded according to the shard key specified in the given input parameter type_id, or randomly sharded, if no shard key is specified. Note that a type containing a shard key cannot be used to create a replicated table. The default value is false. The supported values are:

  • true
  • false
foreign_keys Semicolon-separated list of foreign keys, of the format '(source_column_name [, ...]) references target_table_name(primary_key_column_name [, ...]) [as foreign_key_name]'.
foreign_shard_key Foreign shard key of the format 'source_column references shard_by_column from target_table(primary_key_column)'.
partition_type

Partitioning scheme to use.

Supported Values Description
RANGE Use range partitioning.
INTERVAL Use interval partitioning.
LIST Use list partitioning.
HASH Use hash partitioning.
partition_keys Comma-separated list of partition keys, which are the columns or column expressions by which records will be assigned to partitions defined by partition_definitions.
partition_definitions Comma-separated list of partition definitions, whose format depends on the choice of partition_type. See range partitioning, interval partitioning, list partitioning, or hash partitioning for example formats.
is_automatic_partition

If true, a new partition will be created for values which don't fall into an existing partition. Currently only supported for list partitions. The default value is false. The supported values are:

  • true
  • false
ttl For a table, sets the TTL of the table specified in input parameter table_name.
chunk_size Indicates the number of records per chunk to be used for this table.
is_result_table

For a table, indicates whether the table is an in-memory table. A result table cannot contain store_only, text_search, or string columns (charN columns are acceptable), and it will not be retained if the server is restarted. The default value is false. The supported values are:

  • true
  • false
strategy_definition The tier strategy for the table and its columns. See tier strategy usage for format and tier strategy examples for examples.

Output Parameter Description

Name Type Description
table_name string Value of input parameter table_name.
type_id string Value of input parameter type_id.
is_collection boolean Indicates if the created entity is a collection.
info map of string to strings Additional information.