CREATE TABLE
Creates a new table in the specified (or current) keyspace.
If the table already exists, no table is created and the statement returns an error.
Use IF NOT EXISTS to suppress the error message.
Syntax
CREATE TABLE [ IF NOT EXISTS ] [<keyspace_name>.]<table_name>
( <column_definition> [ , ... ]
[ , PRIMARY KEY ( ( <partition_key_column_name> [ , ... ] )
[ , ( <clustering_column_name> [ ... ] ) ] ) ] )
[ [ WITH | AND ] <table_options> ]
[ [ WITH | AND ] CLUSTERING ORDER BY ( <clustering_column_name> [ ASC | DESC ] [ , ... ] ) ] ;
| Syntax conventions | Description |
|---|---|
UPPERCASE |
Literal keyword. |
Lowercase |
Not literal. |
|
Variable value. Replace with a user-defined value. |
|
Optional.
Square brackets ( |
|
Group.
Parentheses ( |
|
Or.
A vertical bar ( |
|
Repeatable.
An ellipsis ( |
|
Single quotation ( |
|
Map collection.
Braces ( |
|
Set, list, map, or tuple.
Angle bracke
ts ( |
|
End CQL statement.
A semicolon ( |
|
Separate the command line options from the command arguments with two hyphens ( |
|
Search CQL only: Single quotation marks ( |
|
Search CQL only: Identify the entity and literal value to overwrite the XML element in the schema and solrConfig files. |
Parameters
| Parameter | Description | Default | ||
|---|---|---|---|---|
|
Optional. Name of the keyspace that contains the table. .Keyspace and table name conventions
|
If no name is specified, the current keyspace is used. |
||
|
Name of the table. |
|||
|
List of |
|||
|
Name of the column. |
|||
|
||||
|
List of columns that make up the primary key. The first column is the partition key. If there is more than one column in the partition key, enclose the columns in parentheses. Additional columns are clustering columns. |
|||
|
Name of the partition key column. One or more partition key columns are required. |
|||
|
Name of the clustering column.
Optional. One or more clustering columns can be defined.
Also define |
|
Options
Astra DB supports a single table option, which is specified using the WITH keyword.
| Option | Description | Default |
|---|---|---|
|
Specify comments for the table. |
|
Usage Notes
All tables must have a primary key, made up of a partition key and zero or more clustering columns. A partition key can be a single column or a composite partition key composed of multiple columns. A static column is shared by all rows in a partition and is stored only once per partition. A static column cannot be part of the primary key. Primary keys can include frozen collections and UDTs.