Drop a keyspace
Drops a keyspace from a database and deletes all data in that keyspace.
|
You need an application token with permission to interact with the target database, such as the Database Administrator role. For more information, see Get endpoint and token. |
Result
-
Python
-
TypeScript
-
Java
-
curl
Drops the specified keyspace.
Does not return anything.
Drops the specified keyspace.
Returns a promise that resolves once the operation completes.
Drops the specified keyspace.
Does not return anything.
Drops the specified keyspace.
A successful request returns 204 No Content.
Parameters
-
Python
-
TypeScript
-
Java
-
curl
Use the drop_keyspace method, which belongs to the astrapy.DataAPIDatabaseAdmin class.
Method signature
drop_keyspace(
name: str,
*,
keyspace_admin_timeout_ms: int,
request_timeout_ms: int,
timeout_ms: int,
) -> None
| Name | Type | Summary |
|---|---|---|
|
|
The name of the keyspace to drop. |
|
|
Optional. Whether to wait for the database to become active again before returning. If false, the method returns immediately after issuing the creation request, but you cannot work with the database until it becomes active again. Default: true |
|
|
Optional.
A timeout, in milliseconds, to impose on the underlying API request.
If not provided, the This parameter is aliased as |
Use the dropKeyspace method, which belongs to the DataAPIDbAdmin class.
Method signature
async dropKeyspace(
keyspace: string,
options?: {
timeout?: number | TimeoutDescriptor,
}
): void
| Name | Type | Summary |
|---|---|---|
|
|
The name of the keyspace to drop. |
|
|
Optional.
The options for this operation. See Properties of |
| Name | Type | Summary |
|---|---|---|
|
|
Optional. Whether to wait for the database to become active again before returning. If false, the method returns immediately after issuing the creation request, but you cannot work with the database until it becomes active again. Default: true |
|
|
Optional. The timeout(s) to apply to this method.
You can specify Details about the
|
Use the dropKeyspace method, which belongs to the com.datastax.astra.client.admin.DatabaseAdmin class.
Method signature
void dropKeyspace(String keyspace)
void dropKeyspace(
String keyspace,
DropKeyspaceOptions options
)
| Name | Type | Summary |
|---|---|---|
|
|
The name of the keyspace to drop. |
|
|
Optional.
The options for this operation. See Methods of |
| Method | Parameters | Summary |
|---|---|---|
|
|
Optional. Whether the command should silently succeed even if a keyspace with the given name does not exist. Default: true |
Command signature
curl -sS -L -X DELETE "https://api.astra.datastax.com/v2/databases/DATABASE_ID/keyspaces/KEYSPACE_NAME" \
--header "Authorization: Bearer APPLICATION_TOKEN" \
--header "Content-Type: application/json"
The application token must have sufficient permissions to perform the requested operations, such as the Organization Administrator role.
Examples
The following examples demonstrate how to drop a keyspace.
-
Python
-
TypeScript
-
Java
-
curl
from astrapy import DataAPIClient
client = DataAPIClient("TOKEN")
db_admin = client.get_admin().get_database_admin("https://01234567-...")
db_admin.list_keyspaces()
# ['default_keyspace', 'that_other_one']
db_admin.drop_keyspace("that_other_one")
# the 'drop_keyspace' method call takes a few seconds ...
db_admin.list_keyspaces()
# ['default_keyspace']
import { DataAPIClient } from '@datastax/astra-db-ts'
// Spawn an AstraDbAdmin instance
const admin = new DataAPIClient('TOKEN').admin();
const dbAdmin = admin.dbAdmin('ENDPOINT');
(async function () {
// ['default_keyspace', 'that_other_one']
console.log(await dbAdmin.listKeyspaces());
await dbAdmin.dropKeyspace('that_other_one');
// ['default_keyspace']
console.log(await dbAdmin.listKeyspaces());
})();
package com.datastax.astra.client.database_admin;
import com.datastax.astra.client.DataAPIClient;
import com.datastax.astra.client.databases.Database;
public class DropKeyspace {
public static void main(String[] args) {
// Default initialization
Database db = new DataAPIClient("TOKEN")
.getDatabase("API_ENDPOINT");
// Drop a Namespace
db.getDatabaseAdmin().dropKeyspace("<keyspace_name>");
}
}
curl -sS -L -X DELETE "https://api.astra.datastax.com/v2/databases/DB_ID/keyspaces/KEYSPACE_NAME" \
--header "Authorization: Bearer APPLICATION_TOKEN" \
--header "Content-Type: application/json"
Client reference
-
Python
-
TypeScript
-
Java
-
curl
For more information, see the client reference.
For more information, see the client reference.
For more information, see the client reference.
Client reference documentation is not applicable for HTTP.