You can use the {product} to perform administrative operations on your {astra-db} databases and keyspaces.
|
Important
|
To perform database operations, you need an application token with permission to create and configure databases, such as the {organization-administrator-role} role. To work within databases, you need an application token with permission to interact with the target database, such as the {database-administrator-role} role. |
When you connect the {product}, you provide an application token that authorizes you to run the CLI commands.
You can create {db-serverless-vector} and {db-serverless} databases.
|
Note
|
If your organization requires that new databases belong to a PCU group, you cannot use the {product} to create databases because it doesn’t support PCU group assignment with database creation. |
Create a database:
astra db create DB_NAME --region REGION --cloud CLOUD_PROVIDER \
-k KEYSPACE --if-not-exist --asyncParameters:
| Name | Type | Summary |
|---|---|---|
|
|
The database name. Database names must follow these rules: common:ROOT:partial$database-name-rules.adoc |
|
|
A valid cloud provider region, depending on your subscription plan and the database type. astra-db-serverless:databases:partial$get-regions-endpoint.adoc |
|
|
The cloud provider ( |
|
|
The name of the database’s initial keyspace.
If omitted, the default is |
|
|
If provided, this makes the operation idempotent. Check for an existing database with the same configuration. |
|
|
By default, the operation is synchronous and waits for the database to become active. Include this option to make the operation asynchronous. |
|
Important
|
By default, the command waits until the database is created and ready to use. You can set To learn more, run |
Get information about one database.
Get database metadata by database ID:
astra db describe DB_IDParameters:
| Name | Type | Summary |
|---|---|---|
|
|
The ID of the target database. See Get your database ID. You can also get metadata by providing the database name, but this doesn’t guarantee uniqueness. |
Result
+------------------+-----------------------------------------+
| Attribute | Value |
+------------------+-----------------------------------------+
| Name | astra_db_client |
| id | 4391daae-016c-49e3-8d0a-b4633a86082c |
| Cloud | GCP |
| Regions | us-east1 |
| Status | ACTIVE |
| Vector | Enabled |
| Default Keyspace | default_keyspace |
| Creation Time | 2024-02-24T01:20:03Z |
| | |
| Keyspaces | [0] default_keyspace |
| | |
| | |
| Regions | [0] us-east1 |
| | |
+------------------+-----------------------------------------+Retrieve the listing of all databases.
List all of your databases:
astra db listResult
+---------------------+--------------+-----------+-------+---+-----------+
| Name | id | Regions | Cloud | V | Status |
+---------------------+--------------+-----------+-------+---+-----------+
| astra_db_client | DB_ID | us-east1 | gcp | ■ | ACTIVE |
+---------------------+--------------+-----------+-------+---+-----------+common:ROOT:partial$terminate-db-warn.adoc
Delete a database and erase all data stored in it.
Delete a database by ID:
astra db delete DB_IDParameters:
| Name | Type | Summary |
|---|---|---|
|
|
The ID of the database to delete. See Get your database ID. You can also delete a database by name. However, {company} recommends using the ID to ensure the correct database is deleted. |
{db-serverless-vector} databases have an initial keyspace named default_keyspace.
You can override the initial keyspace name when you create the database, if desired.
You can create more keyspaces as needed, such as for better application structure.
Create a keyspace in a database:
astra db create-keyspace DB_ID -k KEYSPACE_NAMEParameters:
| Name | Type | Summary |
|---|---|---|
|
|
The ID of the database where you want to create the keyspace. The database must already exist. See Get your database ID. |
|
|
The unique name for the keyspace. Keyspace names must follow these rules: common:ROOT:partial$keyspace-name-rules.adoc |
Get a list of the keyspaces in a database.
List keyspaces in a database:
astra db list-keyspaces DB_IDParameters:
| Name | Type | Summary |
|---|---|---|
|
|
The ID of the database from which to get the keyspaces. See Get your database ID. |
Result
+----------------------------+
| Name |
+----------------------------+
| default_keyspace (default) |
| keyspace2 |
+----------------------------+Delete a keyspace in a database and erase all data stored in that keyspace.
Delete a keyspace:
astra db delete-keyspace DB_ID -k KEYSPACE_NAMEParameters:
| Name | Type | Summary |
|---|---|---|
|
|
The ID of the database where you want to delete a keyspace. See Get your database ID. |
|
|
The name of the keyspace to delete. |