Drop a keyspace
Drops a keyspace from a database and deletes all data in that keyspace.
Result
-
Python
-
TypeScript
-
Java
-
C#
-
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.
Does not return anything.
Drops the specified keyspace.
If the command succeeds, the response indicates the success.
Example successful response:
{
"status": {
"ok": 1
}
}
Parameters
-
Python
-
TypeScript
-
Java
-
C#
-
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.
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. 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 |
Use the DropKeyspaceAsync method, which belongs to the IDatabaseAdmin class.
You can also use DropKeyspace, which is the synchronous version of the method.
Method signature
Task DropKeyspaceAsync(
string keyspace, DropKeyspaceOptions options = null
);
| Name | Type | Summary |
|---|---|---|
|
|
The name of the keyspace to drop. |
|
Optional. Options for this operation. For more information and examples for general options such as timeout, see Customize API interaction. |
Use the dropKeyspace command.
Command signature
curl -sS -L -X POST "API_ENDPOINT/v1" \
--header "Token: APPLICATION_TOKEN" \
--header "Content-Type: application/json" \
--data '{
"dropKeyspace": {"name": "KEYSPACE_NAME"}
}'
| Name | Type | Summary |
|---|---|---|
|
|
The name of the keyspace to drop. |
Examples
The following examples demonstrate how to drop a keyspace.
-
Python
-
TypeScript
-
Java
-
C#
-
curl
from astrapy import DataAPIClient
from astrapy.authentication import UsernamePasswordTokenProvider
from astrapy.constants import Environment
# Get a database
client = DataAPIClient(environment=Environment.HCD)
database = client.get_database(
"API_ENDPOINT",
token=UsernamePasswordTokenProvider("USERNAME", "PASSWORD"),
)
# Get an admin object
admin = database.get_database_admin()
# Drop a keyspace
admin.drop_keyspace("KEYSPACE_NAME")
import {
DataAPIClient,
UsernamePasswordTokenProvider,
} from "@datastax/astra-db-ts";
// Get a database
const client = new DataAPIClient({ environment: "hcd" });
const database = client.db("API_ENDPOINT", {
token: new UsernamePasswordTokenProvider("USERNAME", "PASSWORD"),
});
// Get an admin object
const admin = database.admin({ environment: "hcd" });
// Drop a keyspace
(async function () {
await admin.dropKeyspace("KEYSPACE_NAME");
})();
import com.datastax.astra.client.DataAPIClient;
import com.datastax.astra.client.DataAPIClients;
import com.datastax.astra.client.admin.DatabaseAdmin;
import com.datastax.astra.client.databases.Database;
public class Example {
public static void main(String[] args) {
// Get a database
DataAPIClient client = DataAPIClients.clientHCD("USERNAME", "PASSWORD");
Database database = client.getDatabase("API_ENDPOINT", "KEYSPACE_NAME");
// Get an admin object
DatabaseAdmin admin = database.getDatabaseAdmin();
// Drop a keyspace
admin.dropKeyspace("KEYSPACE_NAME");
}
}
using DataStax.AstraDB.DataApi;
using DataStax.AstraDB.DataApi.Core;
namespace Examples;
public class Program
{
static async Task Main()
{
// Get an existing database
var client = new DataAPIClient(
new CommandOptions() { Destination = DataAPIDestination.HCD }
);
var database = client.GetDatabase(
"API_ENDPOINT",
DataAPIClient.UsernamePasswordTokenProvider(
"USERNAME",
"PASSWORD"
)
);
var databaseAdmin = database.GetAdmin();
await databaseAdmin.DropKeyspaceAsync("KEYSPACE_NAME");
}
}
curl -sS -L -X POST "API_ENDPOINT/v1" \
--header "Token: APPLICATION_TOKEN" \
--header "Content-Type: application/json" \
--data '{
"dropKeyspace": {"name": "KEYSPACE_NAME"}
}'
Client reference
-
Python
-
TypeScript
-
Java
-
C#
-
curl
For more information, see the client reference.
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.