Manage keyspaces

A keyspace is the top-level database object that controls the replication for the object it contains at each datacenter in the cluster. Keyspaces contain tables, materialized views and user-defined types, functions, and aggregates. Typically, a cluster has one keyspace per application. Because replication is controlled on a per-keyspace basis, store data with different replication requirements in the same region in different keyspaces. Keyspaces are not a significant map layer within the data model.

The following information is provided for informational purposes for Astra DB users. Astra DB uses the NetworkTopologyStrategy, which is controlled by Astra DB and cannot be modified.

Replication strategy and factor

In Astra, keyspaces hold the datacenter names associated with your Astra regions and defines the replication factor (3 for writes in LOCAL_QUORUM) for each datacenter. A replication factor of 3 ensures against losing your data. You can create keyspaces either with the Astra Dashboard or the DevOps API.

When you create or modify a keyspace, the SimpleStrategy replication strategy class is automatically assigned.

SimpleStrategy class is intended for evaluating DataStax Enterprise. For production use or for use with mixed workloads, use the NetworkTopologyStrategy class.

You can also use NetworkTopologyStrategy for evaluation purposes by changing the default snitch, SimpleSnitch, to a network-aware snitch. Choose a snitch and define one or more datacenter names in the snitch properties file, and then use the datacenter name(s) to set the keyspace replication factor. For example, if the cluster uses the GossipingPropertyFileSnitch, create the keyspace using the user-defined datacenter and rack names in the file. If the cluster uses the Configuring the Amazon EC2 single-region snitch, create the keyspace using EC2 datacenter and rack names. If the cluster uses the Configuring the Google Cloud Platform snitch, create the keyspace using GoogleCloud datacenter and rack names.

Showing the keyspace details

In cqlsh, the DESCRIBE KEYSPACE command outputs the full details of the keyspace, including all database objects the keyspace contains. Use the output from the DESCRIBE command to recreate the keyspace and all its components.

The output includes all settings for tables and other objects including the default settings. When recreating a keyspace in another environment, verify that the settings are compatible, such as the keyspace replication factor datacenter names.

Adding a new keyspace

Creating a database with multiple keyspaces allows you to create different data models for each keyspace or store unique data in unique keyspaces. Multiple keyspaces within a single region allows for an application built on a per-keyspace data model.

  1. Open a browser, navigate to Astra DB, and sign in.

  1. On the Dashboard page, select the database name to access the Overview page for your selected database.

  1. Select Add Keyspace.

  1. Enter the new keyspace name. When creating your new keyspace name, make sure you meet the following requirements:

    • No empty spaces or null

    • A maximum of 48 characters

    • Only use alphanumeric characters and/or underscores

  1. Select Save.

Your list of keyspaces displays on the Overview page for your database.

Deleting a keyspace

If you delete a keyspace, all data in that keyspace is removed and cannot be recovered.

  1. Open a browser, navigate to DataStax Astra DB, and sign in.

  1. On the Dashboard page, select the database name to access the Overview page for your selected database.

  1. Select the overview menu (…​) for the keyspace you want to delete.

  1. Select Delete.

  1. In the Delete keyspace menu, type in the name of the keyspace to delete.

  1. Select Delete Keyspace.

Your list of keyspaces will be updated on the Overview page to show only the remaining keyspaces for your database.

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,