5.5 KiB
title | description | menu | weight | list_code_example | related | ||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Delete a database | Use the [`influxctl database delete` command](/influxdb3/cloud-dedicated/reference/cli/influxctl/database/delete/) or the [Management HTTP API](/influxdb3/cloud-dedicated/api/management/) to delete a database from your InfluxDB Cloud Dedicated cluster. Provide the name of the database you want to delete. |
|
203 | ##### CLI ```sh influxctl database delete <DATABASE_NAME> ``` ##### API ```sh curl \ --location "https://console.influxdata.com/api/v0/accounts/ACCOUNT_ID/clusters/CLUSTER_ID/databases/DATABASE_NAME" \ --request DELETE \ --header "Accept: application/json" \ --header "Authorization: Bearer MANAGEMENT_TOKEN" ``` |
|
Use the influxctl
CLI
or the Management HTTP API to create a database in your {{< product-name omit=" Clustered" >}} cluster.
{{% warn %}}
Deleting a database cannot be undone
Once a database is deleted, data stored in that database cannot be recovered.
Cannot reuse database names
After a database is deleted, you cannot reuse the same name for a new database. {{% /warn %}}
{{< tabs-wrapper >}} {{% tabs %}} influxctl Management API {{% /tabs %}} {{% tab-content %}}
-
If you haven't already, download and install the
influxctl
CLI, and then configure aninfluxctl
connection profile for your cluster. -
In your terminal, run the
influxctl database delete
command and provide the following:- Name of the database to delete
-
Confirm that you want to delete the database.
{{% code-placeholders "DATABASE_NAME" %}}
influxctl database delete DATABASE_NAME
{{% /code-placeholders %}}
{{% /tab-content %}} {{% tab-content %}}
This example uses cURL to send a Management HTTP API request, but you can use any HTTP client.
-
If you haven't already, follow the instructions to install cURL for your system.
-
In your terminal, use cURL to send a request to the following {{% product-name %}} endpoint:
{{% api-endpoint endpoint="https://console.influxdata.com/api/v0/accounts/ACCOUNT_ID/clusters/CLUSTER_ID/databases/DATABASE_NAME" method="delete" api-ref="/influxdb3/cloud-dedicated/api/management/#operation/DeleteClusterDatabase" %}}
In the URL, provide the following:
ACCOUNT_ID
: The ID of the account that the cluster belongs to (see how to list cluster details).CLUSTER_ID
: The ID of the cluster that you want to manage (see how to list cluster details).DATABASE_NAME
: The name of the database that you want to delete (see how to list databases).
Provide the following request headers:
Accept: application/json
to ensure the response body is JSON contentAuthorization: Bearer
and a Management API token for your cluster (see how to create a management token for Management API requests).
Specify the
DELETE
request method.
The following example shows how to use the Management API to delete a database:
{{% code-placeholders "DATABASE_NAME|ACCOUNT_ID|CLUSTER_ID|MANAGEMENT_TOKEN" %}}
curl \
--location "https://console.influxdata.com/api/v0/accounts/ACCOUNT_ID/clusters/CLUSTER_ID/databases/DATABASE_NAME" \
--request DELETE \
--header "Accept: application/json" \
--header "Authorization: Bearer MANAGEMENT_TOKEN"
{{% /code-placeholders %}}
Replace the following in your request:
- {{% code-placeholder-key %}}
ACCOUNT_ID
{{% /code-placeholder-key %}}: the ID of the {{% product-name %}} account to create the database for - {{% code-placeholder-key %}}
CLUSTER_ID
{{% /code-placeholder-key %}}: the ID of the {{% product-name %}} cluster to create the database for - {{% code-placeholder-key %}}
MANAGEMENT TOKEN
{{% /code-placeholder-key %}}: a management token for your {{% product-name %}} cluster - {{% code-placeholder-key %}}
DATABASE_NAME
{{% /code-placeholder-key %}}: your {{% product-name %}} database
{{% /tab-content %}} {{< /tabs-wrapper >}}