column_definition

Enclosed in parentheses after the table name, use a comma-separated list to define multiple columns. All tables must have at least one Primary key column. Each column is defined using the following syntax: column_name cql_type_definition [STATIC | PRIMARY KEY] [, ...]

Restrictions:
  • When the primary key is at the end of a column definition, that column is the only primary key for the table.

  • A table must have at least one PRIMARY KEY.

  • A static column cannot be a primary key.

  • Primary keys can include frozen collections.


column_name

Use a unique name for each column in a table. To preserve case or use special characters, enclose the name in double-quotes.

cql_type_definition

Defines the type of data allowed in the column. See CQL data type or a user-defined type.

STATIC

Optional, the column has a single value.

PRIMARY KEY

When the PRIMARY KEY is one column, append PRIMARY KEY to the end of the column definition. This is only schema information required to create a table. When there is one primary key, it is the partition key; the data is divided and stored by the unique values in this column: column_name cql_type_definition PRIMARY KEY.

Alternatively, you can declare the primary key consisting of only one column in the same way as you declare a compound primary key.

Was this helpful?

Give Feedback

How can we improve the documentation?

© 2024 DataStax | Privacy policy | Terms of use

Apache, Apache Cassandra, Cassandra, Apache Tomcat, Tomcat, Apache Lucene, Apache Solr, Apache Hadoop, Hadoop, Apache Pulsar, Pulsar, Apache Spark, Spark, Apache TinkerPop, TinkerPop, Apache Kafka and Kafka are either registered trademarks or trademarks of the Apache Software Foundation or its subsidiaries in Canada, the United States and/or other countries. Kubernetes is the registered trademark of the Linux Foundation.

General Inquiries: +1 (650) 389-6000, info@datastax.com