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