> ## Documentation Index
> Fetch the complete documentation index at: https://docs.kinetica.com/llms.txt
> Use this file to discover all available pages before exploring further.

# /create/table

```
URL: http://<db.host>:<db.port>/create/table
```

Creates a new table with the given type (definition of columns).  The type is
specified in input parameter *type\_id* as either a numerical type ID (as
returned by [/create/type](/content/api/rest/create_type_rest)) or as a list of
columns, each specified as a list of the column name, data type, and any column
attributes.

Example of a type definition with some parameters:

```
[
    ["id", "int8", "primary_key"],
    ["dept_id", "int8", "primary_key", "shard_key"],
    ["manager_id", "int8", "nullable"],
    ["first_name", "char32"],
    ["last_name", "char64"],
    ["salary", "decimal"],
    ["hire_date", "date"]
]
```

Each column definition consists of the column name (which should meet the
standard
[column naming criteria](../../concepts/tables/#table-naming-criteria)),
the column's [specific type](../../concepts/types/#types-chart) (int,
long, float, double, string, bytes, or any of the properties map values from
[/create/type](/content/api/rest/create_type_rest)), and any
[data handling](../../concepts/types/#types-data-handling),
[data key](../../concepts/types/#types-data-keys), or
[data replacement](../../concepts/types/#types-data-replace) properties.

A table may optionally be designated to use a
[replicated](../../concepts/tables/#replication) distribution scheme, or
be assigned: [foreign keys](../../concepts/tables/#foreign-keys) to other
tables, a [partitioning](../../concepts/tables/#partitioning) scheme,
and/or a [tier strategy](../../rm/concepts/#tier-strategies).

## Input Parameter Description

<ParamField body="table_name" type="string">
  Name of the table to be created, in \[schema\_name.]table\_name format, using standard [name resolution rules](../../concepts/tables/#table-name-resolution) and meeting [table naming criteria](../../concepts/tables/#table-naming-criteria). Error for requests with existing table of the same name and type ID may be suppressed by using the *no\_error\_if\_exists* option.
</ParamField>

<ParamField body="type_id" type="string">
  The type for the table, specified as either an existing table's numerical type ID (as returned by [/create/type](/content/api/rest/create_type_rest)) or a type definition (as described above).
</ParamField>

<ParamField body="options" type="map of string to strings">
  Optional parameters.

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

  <Expandable title="options">
    <ParamField body="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
    </ParamField>

    <ParamField body="create_temp_table">
      If *true*, a unique temporary table name will be generated in the sys\_temp schema and used in place of input parameter *table\_name*. If *is\_result\_table* is *true*, then this is always allowed even if the caller does not have permission to create tables. The generated name is returned in *qualified\_table\_name*.

      The default value is `false`.

      The supported values are:

      * true
      * false
    </ParamField>

    <ParamField body="collection_name">
      \[DEPRECATED--please specify the containing schema as part of input parameter *table\_name* and use [/create/schema](/content/api/rest/create_schema_rest) to create the schema if non-existent]  Name of a schema which is to contain the newly created table. If the schema is non-existent, it will be automatically created.
    </ParamField>

    <ParamField body="is_collection">
      \[DEPRECATED--please use [/create/schema](/content/api/rest/create_schema_rest) to create a schema instead]  Indicates whether to create a schema instead of a table.

      The default value is `false`.

      The supported values are:

      * true
      * false
    </ParamField>

    <ParamField body="is_replicated">
      Affects the [distribution scheme](../../concepts/tables/#distribution) for the table's data.  If *true* and the given type has no explicit [shard key](../../concepts/tables/#shard-key) defined, the table will be [replicated](../../concepts/tables/#replication). If *false*, the table will be [sharded](../../concepts/tables/#sharding) according to the shard key specified in the given input parameter *type\_id*, or [randomly sharded](../../concepts/tables/#random-sharding), 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
    </ParamField>

    <ParamField body="foreign_keys">
      Semicolon-separated list of [foreign keys](../../concepts/tables/#foreign-keys), of the format '(source\_column\_name \[, ...]) references target\_table\_name(primary\_key\_column\_name \[, ...]) \[as foreign\_key\_name]'.
    </ParamField>

    <ParamField body="foreign_shard_key">
      Foreign shard key of the format 'source\_column references shard\_by\_column from target\_table(primary\_key\_column)'.
    </ParamField>

    <ParamField body="partition_type">
      [Partitioning](../../concepts/tables/#partitioning) scheme to use.

      * **RANGE**: Use [range partitioning](../../concepts/tables/#partitioning-by-range).
      * **INTERVAL**: Use [interval partitioning](../../concepts/tables/#partitioning-by-interval).
      * **LIST**: Use [list partitioning](../../concepts/tables/#partitioning-by-list).
      * **HASH**: Use [hash partitioning](../../concepts/tables/#partitioning-by-hash).
      * **SERIES**: Use [series partitioning](../../concepts/tables/#partitioning-by-series).
    </ParamField>

    <ParamField body="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*.
    </ParamField>

    <ParamField body="partition_definitions">
      Comma-separated list of partition definitions, whose format depends on the choice of *partition\_type*.  See [range partitioning](../../concepts/tables/#partitioning-by-range), [interval partitioning](../../concepts/tables/#partitioning-by-interval), [list partitioning](../../concepts/tables/#partitioning-by-list), [hash partitioning](../../concepts/tables/#partitioning-by-hash), or [series partitioning](../../concepts/tables/#partitioning-by-series) for example formats.
    </ParamField>

    <ParamField body="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](../../concepts/tables/#partitioning-by-list).

      The default value is `false`.

      The supported values are:

      * true
      * false
    </ParamField>

    <ParamField body="ttl">
      Sets the [TTL](../../concepts/ttl/) of the table specified in input parameter *table\_name*.
    </ParamField>

    <ParamField body="chunk_size">
      Indicates the number of records per chunk to be used for this table.
    </ParamField>

    <ParamField body="chunk_column_max_memory">
      Indicates the target maximum data size for each column in a chunk to be used for this table.
    </ParamField>

    <ParamField body="chunk_max_memory">
      Indicates the target maximum data size for all columns in a chunk to be used for this table.
    </ParamField>

    <ParamField body="is_result_table">
      Indicates whether the table is a [memory-only table](../../concepts/tables_memory_only/). A result table cannot contain columns with text\_search [data-handling](../../concepts/types/#data-handling), and it will not be retained if the server is restarted.

      The default value is `false`.

      The supported values are:

      * true
      * false
    </ParamField>

    <ParamField body="strategy_definition">
      The [tier strategy](../../rm/concepts/#tier-strategies) for the table and its columns.
    </ParamField>

    <ParamField body="compression_codec">
      The default [compression codec](../../concepts/column_compression/) for this table's columns.
    </ParamField>

    <ParamField body="load_vectors_policy">
      Set startup data loading scheme for the table.

      The default value is `system`.

      * **always**: Load as much vector data as possible into memory before accepting requests.
      * **lazy**: Load the necessary vector data at start, and load the remainder lazily.
      * **on\_demand**: Load vector data as requests use it.
      * **system**: Load vector data using the system-configured default.
    </ParamField>

    <ParamField body="build_pk_index_policy">
      Set startup primary-key index generation scheme for the table.

      The default value is `system`.

      * **always**: Generate as much primary key index data as possible before accepting requests.
      * **lazy**: Generate the necessary primary key index data at start, and load the remainder lazily.
      * **on\_demand**: Generate primary key index data as requests use it.
      * **system**: Generate primary key index data using the system-configured default.
    </ParamField>
  </Expandable>
</ParamField>

## Output Parameter Description

The Kinetica server embeds the endpoint response inside a standard response structure which contains status information and the actual response to the query.  Here is a description of the various fields of the wrapper:

<ResponseField name="status" type="String">
  'OK' or 'ERROR'
</ResponseField>

<ResponseField name="message" type="String">
  Empty if success or an error message
</ResponseField>

<ResponseField name="data_type" type="String">
  'create\_table\_response' or 'none' in case of an error
</ResponseField>

<ResponseField name="data" type="String">
  Empty string
</ResponseField>

<ResponseField name="data_str" type="JSON or String">
  This embedded JSON represents the result of the /create/table endpoint:

  <Expandable title="data_str">
    <ResponseField name="table_name" type="string">
      Value of input parameter *table\_name*.
    </ResponseField>

    <ResponseField name="type_id" type="string">
      Value of input parameter *type\_id*.
    </ResponseField>

    <ResponseField name="is_collection" type="boolean">
      \[DEPRECATED--this will always return false]  Indicates if the created entity is a schema.
    </ResponseField>

    <ResponseField name="info" type="map of string to strings">
      Additional information.

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

      <Expandable title="info">
        <ResponseField name="qualified_table_name">
          The fully qualified name of the new table (i.e. including the schema).
        </ResponseField>
      </Expandable>
    </ResponseField>
  </Expandable>

  Empty string in case of an error.
</ResponseField>
