Drop a database
|
Terminating a database permanently deletes all of its data, including automatic backups. You cannot undo this action. |
Delete a database and erase all data stored in it.
|
You need an application token with permission to create and configure databases, such as the Organization Administrator role. For more information, see Get endpoint and token. |
Result
-
Python
-
TypeScript
-
Java
-
curl
The method returns None upon successful database deletion.
Returns:
Promise<void> - A promise that resolves when the database is terminated.
Returns:
boolean - Flag indicating if the database was deleted.
Returns:
A successful request returns 202 Accepted and initiates the termination process.
The database isn’t instantly deleted, and the termination process can take some time.
To monitor the termination process, you can check the database status in the Astra Portal.
Parameters
-
Python
-
TypeScript
-
Java
-
curl
The database deletion is done through an instance of the AstraDBAdmin class.
admin.drop_database("DATABASE_ID")
Parameters:
| Name | Type | Summary |
|---|---|---|
|
|
The ID of the target database. |
|
|
If true (default), the method returns only after the database is actually been deleted. If false, it returns immediately after issuing the drop request, and it is the responsibility of the caller to check the database status/availability after that, if desired. |
|
|
A timeout, in milliseconds, for the whole requested operation to complete. This is relevant only if Note that a timeout event is no guarantee that the deletion request has not reached the API server. If omitted, the corresponding setting from the admin’s API Options is used. |
|
|
A timeout, in milliseconds, for each underlying DevOps API HTTP request. If omitted, the corresponding setting from the admin’s API Options is used. |
|
|
An alias for both the If omitted, the corresponding setting from the admin’s API Options is used. |
The database termination is done through an instance of the AstraAdmin class.
await admin.dropDatabase('DB_ID');
Parameters:
| Name | Type | Summary |
|---|---|---|
|
|
The ID of the target database. |
|
Options regarding the termination of the database. |
|
By default, the |
The delete database function is available in the AstraDBAdmin class.
// Given 'admin', a AstraDBAdmin object
// Delete an existing database by name
admin.dropDatabase(String name);
// Delete an existing database by ID
admin.dropDatabase(UUID id);
Parameters:
| Name | Type | Summary |
|---|---|---|
|
|
The identifier of the database to delete. |
|
|
The name of the database to delete. |
Use the DevOps API to delete a database. This operation is a POST request with no body.
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 database.
-
Python
-
TypeScript
-
Java
-
curl
from astrapy import DataAPIClient
client = DataAPIClient("TOKEN")
admin = client.get_admin()
database_list_pre = list(admin.list_databases())
len(database_list_pre)
# 3
admin.drop_database("01234567-...")
# the 'drop_database' method will take some time ...
database_list_post = list(admin.list_databases())
len(database_list_post)
# 2
import { DataAPIClient } from '@datastax/astra-db-ts'
const admin = new DataAPIClient('TOKEN').admin();
(async function () {
await admin.dropDatabase('DB_ID');
})();
package com.datastax.astra.client.admin;
import com.datastax.astra.client.DataAPIClient;
import java.util.UUID;
public class DropDatabase {
public static void main(String[] args) {
AstraDBAdmin astraDBAdmin = new DataAPIClient("TOKEN").getAdmin();
// Delete an existing database
astraDBAdmin.dropDatabase("<database_name>");
// Delete an existing database by ID
astraDBAdmin.dropDatabase(UUID.fromString("<database_id>"));
}
}
curl -sS -L -X POST "https://api.astra.datastax.com/v2/databases/DB_ID/terminate" \
--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.