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 |
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 in the Astra Portal or with 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 |
Show 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. |
Add a 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.
-
In the Astra Portal, go to Databases, and click your database’s name.
-
Click Add Keyspace.
-
Enter a keyspace name that meets the following requirements:
-
No empty spaces or null
-
A maximum of 48 characters
-
Only alphanumeric characters and underscores
-
-
Click Save.
Delete a keyspace
If you delete a keyspace, all data in that keyspace is removed and can’t be recovered. |
-
In the Astra Portal, go to Databases, and click your database’s name.
-
Locate the keyspace that you want to delete, click
More, and then click Delete. -
To confirm deletion, enter the keyspace name, and then click Delete Keyspace.
The keyspace and all of its data are permanently deleted.