---
title: "Switch Operations to a Different Database"
url: "https://docs.ravendb.net/6.2/client-api/operations/how-to/switch-operations-to-a-different-database"
version: "6.2"
language: "java"
---

# Switch Operations to a Different Database

> Client language: Java. Also available for [C#](https://docs.ravendb.net/6.2/client-api/operations/how-to/switch-operations-to-a-different-database.md), [Python](https://docs.ravendb.net/6.2/client-api/operations/how-to/switch-operations-to-a-different-database.python.md), [PHP](https://docs.ravendb.net/6.2/client-api/operations/how-to/switch-operations-to-a-different-database.php.md), [Node.js](https://docs.ravendb.net/6.2/client-api/operations/how-to/switch-operations-to-a-different-database.nodejs.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."

By default, the operations available directly in store are working on a default database that was setup for that store. To switch operations to a different database that is available on that server use the **forDatabase** method.

## Operations.forDatabase

```java
OperationExecutor forDatabase(String databaseName);
```

| Parameters | | |
| - | - | - |
| **databaseName** | String | Name of a database for which you want to get new Operations |

| Return Value | |
| - | - |
| OperationExecutor | New instance of Operations that is scoped to the requested database |

### Example

```java
OperationExecutor operations = documentStore.operations().forDatabase("otherDatabase");
```

## How to Switch Maintenance Operations to a Different Database

As with `operations`, by default the `maintenance` operations available directly in store are working on a default database that was setup for that store. To switch maintenance operations to a different database use the **forDatabase** method.

## Maintenance.forDatabase

```java
MaintenanceOperationExecutor forDatabase(String databaseName);
```

| Parameters | | |
| - | - | - |
| **databaseName** | String | Name of a database for which you want to get new maintenance operations |

| Return Value | |
| - | - |
| MaintenanceOperationExecutor | New instance of maintenance that is scoped to the requested database |

### Example

```java
MaintenanceOperationExecutor maintenanceOperations = documentStore.maintenance().forDatabase("otherDatabase");
```

## See also

- [What are Operations](https://docs.ravendb.net/6.2/client-api/operations/what-are-operations.java.md)
