---
title: "Operations: Server: How to delete a database?"
url: "https://docs.ravendb.net/6.2/client-api/operations/server-wide/delete-database"
version: "6.2"
language: "java"
---

# Operations: Server: How to delete a database?

> Client language: Java. Also available for [C#](https://docs.ravendb.net/6.2/client-api/operations/server-wide/delete-database.md).
>
> RavenDB publishes an official agent skill for coding assistants at https://docs.ravendb.net/skills/ravendb/SKILL.md (also installable with `npx skills add ravendb/skills`). The skill describes itself as: "Read this before writing any RavenDB query, client call or /databases/ request. Covers server setup, document modelling, the Node.js, .NET and Python clients, RQL, indexes, vector search and AI agents. Code written from recall tends to run and return the wrong rows, because RQL resembles SQL and the clients take field names as plain strings."

This operation is used to delete databases from a server, with a possibility to remove all the data from hard drive.

## Syntax

```java
public DeleteDatabasesOperation(String databaseName, boolean hardDelete)

public DeleteDatabasesOperation(String databaseName, boolean hardDelete, String fromNode)

public DeleteDatabasesOperation(String databaseName, boolean hardDelete, String fromNode, Duration timeToWaitForConfirmation)

public DeleteDatabasesOperation(Parameters parameters)
```

```java
public static class Parameters {
  private String[] databaseNames;
  private boolean hardDelete;
  private String[] fromNodes;
  private Duration timeToWaitForConfirmation;

  public String[] getDatabaseNames() {
      return databaseNames;
  }

  public void setDatabaseNames(String[] databaseNames) {
      this.databaseNames = databaseNames;
  }

  public boolean isHardDelete() {
      return hardDelete;
  }

  public void setHardDelete(boolean hardDelete) {
      this.hardDelete = hardDelete;
  }

  public String[] getFromNodes() {
      return fromNodes;
  }

  public void setFromNodes(String[] fromNodes) {
      this.fromNodes = fromNodes;
  }

  public Duration getTimeToWaitForConfirmation() {
      return timeToWaitForConfirmation;
  }

  public void setTimeToWaitForConfirmation(Duration timeToWaitForConfirmation) {
      this.timeToWaitForConfirmation = timeToWaitForConfirmation;
  }
}
```

| Parameters | | |
| - | - | - |
| **DatabaseName** | String | Name of a database to delete |
| **HardDelete** | boolean | Should all data be removed (data files, indexing files, etc.). |
| **FromNode** | String | Remove the database just from a specific node. Default: `null` which would delete from all |
| **TimeToWaitForConfirmation** | Duration | Time to wait for confirmation. Default: `null` will user server default (15 seconds) |

## Example I

```java
DeleteDatabasesOperation.Parameters parameters = new DeleteDatabasesOperation.Parameters();
parameters.setDatabaseNames(new String[]{ "MyNewDatabase", "OtherDatabaseToDelete" });
parameters.setHardDelete(true);
parameters.setFromNodes(new String[]{ "A", "C" }); //optional
parameters.setTimeToWaitForConfirmation(Duration.ofSeconds(30)); // optional

store.maintenance()
  .server().send(new DeleteDatabasesOperation(parameters));
```

## Example II

In order to delete just one database from a server, you can also use this constructor

```java
store.maintenance().server().send(
  new DeleteDatabasesOperation("MyNewDatabase", true, null, null));
```
