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

# ALTER EXTERNAL CONNECTION

export const InternalLink = ({version, path = "", children, ...props}) => {
  let detectedVersion = version || "stable";
  if (typeof window !== 'undefined' && !version) {
    const match = window.location.pathname.match(/\/docs\/([^/]+)/);
    if (match) {
      detectedVersion = match[1];
    }
  }
  const normalizedPath = path.startsWith("/") ? path.slice(1) : path;
  return <a href={`/docs/${detectedVersion}/${normalizedPath}`} {...props}>
      {children}
    </a>;
};

The `ALTER EXTERNAL CONNECTION` <InternalLink path="sql-statements">statement</InternalLink> 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:

* <InternalLink path="create-external-connection">`CREATE EXTERNAL CONNECTION`</InternalLink>
* <InternalLink path="show-external-connection">`SHOW EXTERNAL CONNECTION`</InternalLink>
* <InternalLink path="show-create-external-connection">`SHOW CREATE EXTERNAL CONNECTION`</InternalLink>
* <InternalLink path="drop-external-connection">`DROP EXTERNAL CONNECTION`</InternalLink>

## 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

<img src="https://mintcdn.com/cockroachlabs/M1Nto-joXUTgisRs/images/sql-diagrams/v25.4/alter_external_connection.svg?fit=max&auto=format&n=M1Nto-joXUTgisRs&q=85&s=3bfbf3883d0bac5a06e2a936b9843080" alt="alter_external_connection syntax diagram" style={{maxWidth: "100%", overflowX: "auto"}} width="751" height="135" data-path="images/sql-diagrams/v25.4/alter_external_connection.svg" />

<img src="https://mintcdn.com/cockroachlabs/3GJF_H8Sra2LZag-/images/generated/docs/v25.4/alter-external-connection/syntax-diagram-f3dfd5868f5d.svg?fit=max&auto=format&n=3GJF_H8Sra2LZag-&q=85&s=9b158f3c10bc56c28724b1d705f4fcd6" alt="SQL syntax diagram" width="751" height="135" data-path="images/generated/docs/v25.4/alter-external-connection/syntax-diagram-f3dfd5868f5d.svg" />

### 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                                |
| --------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------ |
| <InternalLink path="changefeed-sinks#amazon-msk">Amazon MSK</InternalLink>                                                  | Changefeeds                                      |
| <InternalLink path="use-cloud-storage">Amazon S3</InternalLink>                                                             | Backups, restores, imports, exports, changefeeds |
| <InternalLink path="take-and-restore-encrypted-backups#aws-kms-uri-format">Amazon S3 KMS</InternalLink>                     | Encrypted backups                                |
| <InternalLink path="use-cloud-storage">Azure Storage</InternalLink>                                                         | Backups, restores, imports, exports, changefeeds |
| <InternalLink path="changefeed-sinks#confluent-cloud">Confluent Cloud</InternalLink>                                        | Changefeeds                                      |
| <InternalLink path="create-changefeed">Confluent Schema Registry</InternalLink>                                             | Changefeeds                                      |
| <InternalLink path="changefeed-sinks">Google Cloud Pub/Sub</InternalLink>                                                   | Changefeeds                                      |
| <InternalLink path="use-cloud-storage">Google Cloud Storage</InternalLink>                                                  | Backups, restores, imports, exports, changefeeds |
| <InternalLink path="take-and-restore-encrypted-backups#google-cloud-kms-uri-format">Google Cloud Storage KMS</InternalLink> | Encrypted backups                                |
| <InternalLink path="changefeed-sinks">HTTP(S)</InternalLink>                                                                | Changefeeds                                      |
| <InternalLink path="changefeed-sinks#kafka">Kafka</InternalLink>                                                            | Changefeeds                                      |
| <InternalLink path="use-cloud-storage">Nodelocal</InternalLink>                                                             | Backups, restores, imports, exports, changefeeds |
| <InternalLink path="set-up-physical-cluster-replication#connection-reference">PostgreSQL</InternalLink> connections         | Physical cluster replication                     |
| <InternalLink path="use-userfile-storage">Userfile</InternalLink>                                                           | Backups, restores, imports, exports, changefeeds |
| <InternalLink path="changefeed-sinks#webhook-sink">Webhook</InternalLink>                                                   | 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

* <InternalLink path="create-external-connection">`CREATE EXTERNAL CONNECTION`</InternalLink>
* <InternalLink path="drop-external-connection">`DROP EXTERNAL CONNECTION`</InternalLink>
* <InternalLink path="show-create-external-connection">`SHOW CREATE EXTERNAL CONNECTION`</InternalLink>
