PRIMARY KEY (column_list)

Uniquely identifies rows, determines storage partitions, and orders data (clustering columns) within a partition.

A NULL value cannot be inserted into a PRIMARY KEY column. This restriction applies to both partition keys and clustering columns.

column_list

Defines a partition and clustering columns, which affects how the data in stored.

  • Compound primary key: the first column is the partition key, and the additional columns are clustering keys. Syntax: PRIMARY KEY (<partition_column_name>, <clustering_column_name> [, ...])

  • Composite partition key: Multiple columns in the partition key. Enclose the partition key columns in parentheses. Syntax: PRIMARY KEY ((<partition_column_name>[, ...]),<clustering_column_name> [, ...])

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