|
| 1 | +--- |
| 2 | +title: ALTER EXTERNAL CONNECTION |
| 3 | +summary: Use the ALTER EXTERNAL CONNECTION statement to update an external connection's URI. |
| 4 | +toc: true |
| 5 | +docs_area: reference.sql |
| 6 | +--- |
| 7 | + |
| 8 | +The `ALTER EXTERNAL CONNECTION` [statement]({% link {{ page.version.version }}/sql-statements.md %}) allows you to change the [storage/sink](#supported-external-storage-and-sinks) URI that an external connection references. |
| 9 | + |
| 10 | +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. |
| 11 | + |
| 12 | +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. |
| 13 | + |
| 14 | +You can also use the following SQL statements to work with external connections: |
| 15 | + |
| 16 | +- [`CREATE EXTERNAL CONNECTION`]({% link {{ page.version.version }}/create-external-connection.md %}) |
| 17 | +- [`SHOW EXTERNAL CONNECTION`]({% link {{ page.version.version }}/show-external-connection.md %}) |
| 18 | +- [`SHOW CREATE EXTERNAL CONNECTION`]({% link {{ page.version.version }}/show-create-external-connection.md %}) |
| 19 | +- [`DROP EXTERNAL CONNECTION`]({% link {{ page.version.version }}/drop-external-connection.md %}) |
| 20 | + |
| 21 | +## Required privileges |
| 22 | + |
| 23 | +To update an external connection, a user must have the `UPDATE` privilege on that connection. |
| 24 | + |
| 25 | +For example: |
| 26 | + |
| 27 | +{% include_cached copy-clipboard.html %} |
| 28 | +~~~sql |
| 29 | +GRANT UPDATE ON EXTERNAL CONNECTION backup_bucket TO user; |
| 30 | +~~~ |
| 31 | + |
| 32 | +## Synopsis |
| 33 | + |
| 34 | +<div> |
| 35 | +{% remote_include https://raw.githubusercontent.com/cockroachdb/generated-diagrams/{{ page.release_info.crdb_branch_name }}/grammar_svg/alter_external_connection.html %} |
| 36 | +</div> |
| 37 | + |
| 38 | +### Parameters |
| 39 | + |
| 40 | +Parameter | Description |
| 41 | +----------+------------- |
| 42 | +`connection_name` | The name of the existing external connection. |
| 43 | +`connection_uri` | The new [storage/sink](#supported-external-storage-and-sinks) URI that the external connection will be updated to reference. |
| 44 | + |
| 45 | +## Supported external storage and sinks |
| 46 | + |
| 47 | +Storage or sink | Operation support |
| 48 | +---------------------+--------------------------------- |
| 49 | +[Amazon MSK]({% link {{ page.version.version }}/changefeed-sinks.md %}#amazon-msk) | Changefeeds |
| 50 | +[Amazon S3]({% link {{ page.version.version }}/use-cloud-storage.md %}) | Backups, restores, imports, exports, changefeeds |
| 51 | +[Amazon S3 KMS]({% link {{ page.version.version }}/take-and-restore-encrypted-backups.md %}#aws-kms-uri-format) | Encrypted backups |
| 52 | +[Azure Storage]({% link {{ page.version.version }}/use-cloud-storage.md %}) | Backups, restores, imports, exports, changefeeds |
| 53 | +[Confluent Cloud]({% link {{ page.version.version }}/changefeed-sinks.md %}#confluent-cloud) | Changefeeds |
| 54 | +[Confluent Schema Registry]({% link {{ page.version.version }}/create-changefeed.md %}#confluent-schema-registry) | Changefeeds |
| 55 | +[Google Cloud Pub/Sub]({% link {{ page.version.version }}/changefeed-sinks.md %}#google-cloud-pub-sub) | Changefeeds |
| 56 | +[Google Cloud Storage]({% link {{ page.version.version }}/use-cloud-storage.md %}) | Backups, restores, imports, exports, changefeeds |
| 57 | +[Google Cloud Storage KMS]({% link {{ page.version.version }}/take-and-restore-encrypted-backups.md %}#google-cloud-kms-uri-format) | Encrypted backups |
| 58 | +[HTTP(S)]({% link {{ page.version.version }}/changefeed-sinks.md %}) | Changefeeds |
| 59 | +[Kafka]({% link {{ page.version.version }}/changefeed-sinks.md %}#kafka) | Changefeeds |
| 60 | +[Nodelocal]({% link {{ page.version.version }}/use-cloud-storage.md %}) | Backups, restores, imports, exports, changefeeds |
| 61 | +[PostgreSQL]({% link {{ page.version.version }}/set-up-physical-cluster-replication.md %}#connection-reference) connections | Physical cluster replication |
| 62 | +[Userfile]({% link {{ page.version.version }}/use-userfile-storage.md %}) | Backups, restores, imports, exports, changefeeds |
| 63 | +[Webhook]({% link {{ page.version.version }}/changefeed-sinks.md %}#webhook-sink) | Changefeeds |
| 64 | + |
| 65 | +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. |
| 66 | + |
| 67 | +## Examples |
| 68 | + |
| 69 | +### Update the URI of an external connection |
| 70 | + |
| 71 | +In this example, you update the `backup_bucket` external connection to a new Amazon S3 URI to rotate your auth token. |
| 72 | + |
| 73 | +{% include_cached copy-clipboard.html %} |
| 74 | +~~~sql |
| 75 | +ALTER EXTERNAL CONNECTION backup_bucket AS 's3://bucket name?AWS_ACCESS_KEY_ID={new access key}&AWS_SECRET_ACCESS_KEY={new secret access key}'; |
| 76 | +~~~ |
| 77 | + |
| 78 | +## See also |
| 79 | + |
| 80 | +- [`CREATE EXTERNAL CONNECTION`]({% link {{ page.version.version }}/create-external-connection.md %}) |
| 81 | +- [`DROP EXTERNAL CONNECTION`]({% link {{ page.version.version }}/drop-external-connection.md %}) |
| 82 | +- [`SHOW CREATE EXTERNAL CONNECTION`]({% link {{ page.version.version }}/show-create-external-connection.md %}) |
0 commit comments