Manage keyspaces
Astra DB Serverless databases store data in collections and tables, which exist inside keyspaces.
Each Astra DB database must have at least one keyspace, and you can create more as needed. For example, you can categorize your data by data model or separate unique data from your other data.
Prerequisites
-
A role with keyspace permissions, such as the Database Administrator role.
To create keyspaces programmatically, you need an application token with an appropriately scoped role.
Create a keyspace
In Astra DB Serverless databases, you use keyspaces to organize related collections and tables, similar to a schema in a relational database. For example, you can have different data models for each keyspace, store unique data in unique keyspaces, or use multiple keyspaces within a single region to build applications on a per-keyspace data model.
Every database has an initial keyspace, and you can create additional keyspaces.
For Serverless (Vector) databases, the initial keyspace name is default_keyspace.
-
Astra Portal
-
API
-
CLI
-
CQL
-
Serverless (Vector) database
-
Serverless (Non-Vector) database
-
In the Astra Portal, click the name of your Serverless (Vector) database.
-
Click Data Explorer.
-
Click the Keyspace menu, and then select Create Keyspace.
-
Enter a keyspace name.
Rules for keyspace names
-
Must start with a letter or number
-
Can contain letters, numbers, and underscores
-
Cannot exceed 48 characters.
-
Cannot be the reserved words
dseorsystem -
Must be unique within the database
-
-
Click Create Keyspace.
-
In the Astra Portal, click the name of your Serverless (Non-Vector) database.
-
Click Add Keyspace.
-
Enter a keyspace name.
Rules for keyspace names
-
Must start with a letter or number
-
Can contain letters, numbers, and underscores
-
Cannot exceed 48 characters.
-
Cannot be the reserved words
dseorsystem -
Must be unique within the database
-
-
Click Add Keyspace.
You can use the DevOps API or Data API clients to programmatically create keyspaces in Astra DB Serverless databases.
For more information, including examples and parameters, see Create a keyspace.
You can use the Astra CLI to programmatically create keyspaces in Astra DB Serverless databases.
For more information, see astra db create-keyspace.
Astra DB doesn’t support the CQL CREATE KEYSPACE command.
Instead, you must use the Astra Portal, DevOps API, or Astra CLI to create keyspaces.
The database enters Maintenance status while creating the keyspace. When the database returns to Active status, you can use the new keyspace. For example, you can create a collection or table in the keyspace.
Delete a keyspace
|
Deleting a keyspace permanently deletes all collections, tables, and data in the keyspace. Programmatically, it is possible to delete all keyspaces in a database, but DataStax doesn’t recommend this. |
-
Astra Portal
-
API
-
CLI
-
CQL
-
Serverless (Vector) database
-
Serverless (Non-Vector) database
-
In the Astra Portal, click the name of your Serverless (Vector) database.
-
Click Data Explorer.
-
In the Keyspace menu, find the keyspace that you want to delete, and then click delete Delete.
-
To confirm deletion, enter the keyspace name, and then click Delete Keyspace.
-
In the Astra Portal, click the name of your Serverless (Non-Vector) database.
-
In the Keyspaces section, find the keyspace you want to delete, click More, and then click Delete.
-
To confirm deletion, enter the keyspace name, and then click Delete Keyspace.
You can use the DevOps API or Data API clients to programmatically delete keyspaces in Astra DB Serverless databases.
For more information, including examples and parameters, see Drop a keyspace.
You can use the Astra CLI to programmatically delete keyspaces in Astra DB Serverless databases.
For more information, see astra db delete-keyspace.
Astra DB doesn’t support the CQL DROP KEYSPACE command.
Instead, you must use the Astra Portal, DevOps API, or Astra CLI to delete keyspaces.
The database enters Maintenance status while it deletes the keyspace along with any collections, tables, and data within the keyspace.
Troubleshoot keyspaces
- CQL KEYSPACE command errors
-
CQL for Astra DB doesn’t support
KEYSPACEcommands. You must create and delete keyspaces through a non-CQL interface, such as the Astra Portal, DevOps API, or Astra CLI. - Data API client commands fail when passing namespace
-
Namespace is a deprecated term for a keyspace in a Serverless (Vector) database. This term is no longer used in the Astra Portal, and
namespacewas deprecated in version 1.5 of the Data API clients.