CREATE EXTERNAL CONNECTION, you define a name for an external connection while passing the provider URI and query parameters. , , , , and queries can interact with the defined external connection instead of a required, provider-specific URI. As a result, you can decouple the management of the external resource from the operation in which you’re using them.
CREATE EXTERNAL CONNECTION will validate the URI by writing, reading, and listing a test file to the external storage URI. If you’re using a , CREATE EXTERNAL CONNECTION will encrypt and decrypt a file. You’ll find a crdb_external_storage_location file in your external storage as a result of this test. Each of the operations that access the external connection is aware of the raw URI that is parsed to configure, authenticate, and interact with the connection.
The privilege model for external connections means that you can delegate the creation and usage of external connections to the necessary users or roles.
You can also use the following SQL statements to work with external connections:
Required privileges
To create an external connection, a user must have theEXTERNALCONNECTION . root and users have this system-level privilege by default and are capable of granting the EXTERNALCONNECTION system-level privilege to other users and roles with or without the .
For example:
USAGE privilege on that connection:
For example:
Synopsis
Parameters
| Parameter | Description |
|---|---|
connection\_name | The name that represents the external connection. |
connection\_URI | The storage/sink URI that the external connection will reference. |
Supported external storage and sinks
| Storage or sink | Operation support |
|---|---|
| Changefeeds | |
| Backups, restores, imports, exports, changefeeds | |
| Encrypted backups | |
| Backups, restores, imports, exports, changefeeds | |
| Changefeeds | |
| Changefeeds | |
| Changefeeds | |
| Backups, restores, imports, exports, changefeeds | |
| Encrypted backups | |
| Changefeeds | |
| Changefeeds | |
| Backups, restores, imports, exports, changefeeds | |
| connections | Physical cluster replication |
| Backups, restores, imports, exports, changefeeds | |
| Changefeeds |
Changefeed sinks as external connections
Consider the following when you create an external connection for changefeeds:- You can only include the query parameters and options that Kafka sinks support. Refer to the table and the Kafka for more detail.
- To restrict a user’s access to changefeed data and sink credentials, enable the
changefeed.permissions.require_external_connection_sink.enabledcluster setting. When you enable this setting, users with the on a set of tables can only create changefeeds into .
External connection URI format
To form the external connection URI in operation statements, use theexternal:// scheme followed by the name of the external connection.
For an external connection named backup_storage:
Examples
The examples in this section demonstrate some of the storage and operation options that external connections support.Create an external connection for cloud storage
In this example, you create an external connection for an Amazon S3 bucket that will store your backups. Then, you use the external connection to restore the backup to your cluster.-
Define your external connection that references the S3 bucket’s URI:
-
Verify that the new external connection was created successfully with :
-
Run the backup to your S3 bucket using the external connection’s name:
If you are creating an external connection with or parameters, you must pass them in uppercase otherwise you will receive an
unknown query parameterserror. -
Use to view your backups in the storage defined by the external connection:
-
In the event that a restore is necessary, use
RESTOREwith the external connection: -
When you no longer need the external connection, you can delete it with :
Create an external connection for a changefeed sink
In this example, you create an external connection to a Kafka sink to which a changefeed will emit messages. When you create the external connection, you will include the necessary query parameters for your changefeed. As a result, you will only need to specify the external connection’s name when creating a changefeed rather than the Kafka URI and parameters.-
Define your external connection that references the Kafka sink URI and any :
If you are creating an external connection with , you must pass them in lowercase otherwise you will receive an
unknown query parameterserror. -
Create your changefeed using the external connection’s name:

