> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cockroachlabs.com/llms.txt
> Use this file to discover all available pages before exploring further.

# ALTER EXTERNAL CONNECTION

The `ALTER EXTERNAL CONNECTION` [statement](/docs/stable/sql-statements.md) allows you to change the [storage/sink](#supported-external-storage-and-sinks) URI that an external connection references.

You can use external connections to specify and interact with resources that are external to CockroachDB. When creating an external connection, you must define a name for the external connection while passing the provider URI and query parameters.

You can use `ALTER EXTERNAL CONNECTION` to update the connection string for an external connection to use a new authentication token. This allows you to rotate your auth token before the old token expires.

You can also use the following SQL statements to work with external connections:

* [`CREATE EXTERNAL CONNECTION`](/docs/stable/create-external-connection)
* [`SHOW EXTERNAL CONNECTION`](/docs/stable/show-external-connection)
* [`SHOW CREATE EXTERNAL CONNECTION`](/docs/stable/show-create-external-connection)
* [`DROP EXTERNAL CONNECTION`](/docs/stable/drop-external-connection)

## Required privileges

To update an external connection, a user must have the `UPDATE` privilege on that connection.

For example:

```sql theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
GRANT UPDATE ON EXTERNAL CONNECTION backup_bucket TO user;
```

## Synopsis

![alter\_external\_connection syntax diagram](https://mintcdn.com/cockroachlabs/VQ_w3c6MHYdiS7Tn/images/sql-diagrams/common/alter_external_connection.svg?fit=max\&auto=format\&n=VQ_w3c6MHYdiS7Tn\&q=85\&s=6aec0ed1ef5fdeef676d0692adccfa7e)

### Parameters

| Parameter | Description |
| - | - |
| `connection_name` | The name of the existing external connection. |
| `connection_uri` | The new [storage/sink](#supported-external-storage-and-sinks) URI that the external connection will be updated to reference. |

## Supported external storage and sinks

| Storage or sink | Operation support |
| - | - |
| [Amazon MSK](/docs/stable/changefeed-sinks.md#amazon-msk) | Changefeeds |
| [Amazon S3](/docs/stable/use-cloud-storage.md) | Backups, restores, imports, exports, changefeeds |
| [Amazon S3 KMS](/docs/stable/take-and-restore-encrypted-backups.md#aws-kms-uri-format) | Encrypted backups |
| [Azure Storage](/docs/stable/use-cloud-storage.md) | Backups, restores, imports, exports, changefeeds |
| [Confluent Cloud](/docs/stable/changefeed-sinks.md#confluent-cloud) | Changefeeds |
| [Confluent Schema Registry](/docs/stable/create-changefeed.md#confluent-schema-registry) | Changefeeds |
| [Google Cloud Pub/Sub](/docs/stable/changefeed-sinks.md) | Changefeeds |
| [Google Cloud Storage](/docs/stable/use-cloud-storage.md) | Backups, restores, imports, exports, changefeeds |
| [Google Cloud Storage KMS](/docs/stable/take-and-restore-encrypted-backups.md#google-cloud-kms-uri-format) | Encrypted backups |
| [HTTP(S)](/docs/stable/changefeed-sinks.md) | Changefeeds |
| [Kafka](/docs/stable/changefeed-sinks.md#kafka) | Changefeeds |
| [Nodelocal](/docs/stable/use-cloud-storage.md) | Backups, restores, imports, exports, changefeeds |
| [PostgreSQL](/docs/stable/set-up-physical-cluster-replication.md#connection-reference) connections | Physical cluster replication |
| [Userfile](/docs/stable/use-userfile-storage.md) | Backups, restores, imports, exports, changefeeds |
| [Webhook](/docs/stable/changefeed-sinks.md#webhook-sink) | Changefeeds |

For more information on authentication and forming the URI that an external connection will represent, refer to the storage or sink pages linked in the table.

## Examples

### Update the URI of an external connection

In this example, you update the `backup_bucket` external connection to a new Amazon S3 URI to rotate your auth token.

```sql theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
ALTER EXTERNAL CONNECTION backup_bucket AS 's3://bucket name?AWS_ACCESS_KEY_ID={new access key}&AWS_SECRET_ACCESS_KEY={new secret access key}';
```

## See also

* [`CREATE EXTERNAL CONNECTION`](/docs/stable/create-external-connection)
* [`DROP EXTERNAL CONNECTION`](/docs/stable/drop-external-connection)
* [`SHOW CREATE EXTERNAL CONNECTION`](/docs/stable/show-create-external-connection)
