This page describes how to update a Database Connection.

You can update the password secret version, wallet secret version, and labels
of a Database Connection.

When you want to rotate the database or wallet password, add a new secret version,
then update the corresponding property. The service checks access to the new
secret and re-validates connectivity.

## Update a Database Connection

To update a Database Connection, do the following:

### gcloud

Use the `gcloud oracle-database database-connections update` command to
update a Database Connection.

    gcloud oracle-database database-connections update CONNECTION_ID \
        --project=PROJECT_ID \
        --location=REGION \
        --password-secret-version="projects/<var>PROJECT_ID</var>/secrets/<var>SECRET_ID</var>/versions/<var>SECRET_VERSION</var>" \
        --wallet-secret-version="projects/<var>PROJECT_ID</var>/secrets/<var>SECRET_ID</var>/versions/<var>SECRET_VERSION</var>" \
        --update-labels=KEY=VALUE

Replace the following:

- <var translate="no">CONNECTION_ID</var>: the ID of the Database Connection.
- <var translate="no">PROJECT_ID</var>: the ID of your Google Cloud project.
- <var translate="no">REGION</var>: the region where your Database Connection is located.
- For `password-secret-version` property, replace the following:
  - <var translate="no">PROJECT_ID</var>: the ID of your Google Cloud project that contains the secret.
  - <var translate="no">SECRET_ID</var>: the ID of the secret.
  - <var translate="no">SECRET_VERSION</var>: the new version of the secret to use.
- For `wallet-secret-version` property, replace the following:
  - <var translate="no">PROJECT_ID</var>: the ID of your Google Cloud project that contains the database wallet.
  - <var translate="no">SECRET_ID</var>: the ID of the secret.
  - <var translate="no">SECRET_VERSION</var>: the new version of the secret to use.
- For `update-labels` property, replace the following:
  - <var translate="no">KEY</var>: the key of the label.
  - <var translate="no">VALUE</var>: the value of the label.

### API

To update a Database Connection, run the following `curl` command, and include
only the fields that you want to update.

> [!NOTE]
> **Note:** The following `curl` command replaces the full label set, unlike the `gcloud oracle-database database-connections update` command.

```
curl -X PATCH \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json" \
"https://oracledatabase.googleapis.com/v1/projects/PROJECT_ID/locations/REGION/databaseConnections/CONNECTION_ID?updateMask=passwordSecretVersion,walletSecretVersion,labels" \
-d \
'{
  "passwordSecretVersion": "projects/PROJECT_ID/secrets/SECRET_ID/versions/SECRET_VERSION",
  "walletSecretVersion": "projects/PROJECT_ID/secrets/SECRET_ID/versions/SECRET_VERSION",
  "labels": {
    "KEY": "VALUE"
  }
}'
```

Replace the following:

- <var translate="no">PROJECT_ID</var>: the ID of your Google Cloud project.
- <var translate="no">REGION</var>: the region where your Database Connection is located.
- <var translate="no">CONNECTION_ID</var>: the ID of the Database Connection.
- For `passwordSecretVersion` property, replace the following:
  - <var translate="no">PROJECT_ID</var>: the ID of your Google Cloud project that contains the secret.
  - <var translate="no">SECRET_ID</var>: the ID of the secret.
  - <var translate="no">SECRET_VERSION</var>: the new version of the secret to use.
- For `walletSecretVersion` property, replace the following:
  - <var translate="no">PROJECT_ID</var>: the ID of your Google Cloud project that contains the database wallet.
  - <var translate="no">SECRET_ID</var>: the ID of the secret.
  - <var translate="no">SECRET_VERSION</var>: the new version of the secret to use.
- For `labels` property, replace the following:
  - <var translate="no">KEY</var>: the key of the label.
  - <var translate="no">VALUE</var>: the value of the label.