Setting up the cycling keyspace

CQL commands to set up the cycling keyspace for examples used in this documenation.

Use the replication factor that is appropriate for your environment. The following assumes that the Astra DB Serverless deployment is a single node cluster in a development environment.

Update the following command and create a CQL file named keyspace-create-simple.cql in the same directory where you launch cqlsh.

CREATE KEYSPACE IF NOT EXISTS cycling
WITH REPLICATION = {
  'class' : 'SimpleStrategy',
  'replication_factor' : 1
};

Additional cycling keyspace examples

Create a keyspace with a network topology strategy

CREATE KEYSPACE cycling 
WITH REPLICATION = { 
  'class' : 'NetworkTopologyStrategy', 
  'datacenter1' : 1
};

Create a keyspace with multiple data centers

CREATE KEYSPACE IF NOT EXISTS cycling
WITH REPLICATION = {
  'class' : 'NetworkTopologyStrategy',
  'datacenter1': '3', 
  'datacenter2': '3'
};

Create a keyspace with multiple named data centers

-- previously tag::multi
// tag::keyspace-create-Cycling[]
CREATE KEYSPACE "Cycling"
WITH REPLICATION = {
  'class' : 'NetworkTopologyStrategy', 
  'boston'  : 3 , // Datacenter 1 
  'seattle' : 2 , // Datacenter 2
  'tokyo'   : 2   // Datacenter 3
};
// end::keyspace-create-Cycling[]

Create a keyspace with keyspace options

CREATE KEYSPACE cycling
WITH REPLICATION = { 
  'class' : 'NetworkTopologyStrategy',
  'datacenter1' : 3 
} 
AND DURABLE_WRITES = false;

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