Jaa


CREATE EXTERNAL LOCATION

Applies to: check marked yes Databricks SQL check marked yes Databricks Runtime 10.4 LTS and above check marked yes Unity Catalog only

Creates an external location with the specified name. If a location with the same name already exists, an exception is thrown.

For how-to instructions, see Create an external location to connect cloud storage to Azure Databricks.

Syntax

CREATE EXTERNAL LOCATION [IF NOT EXISTS] location_name
    URL url_str
    WITH (STORAGE CREDENTIAL credential_name)
    [COMMENT comment]

Any object name that includes special characters, such as hyphens (-), must be surrounded by backticks (` `). Object names with underscores (_) don’t require backticks. See Names and Examples.

Parameters

  • location_name

    The name of the location to be created.

  • IF NOT EXISTS

    Creates a location with the given name if it does not exist. If a location with the same name already exists, nothing will happen.

  • url_str

    A STRING literal with the location of the cloud storage described as an absolute URL. Must be surrounded by single quotes.

  • credential_name

    The named credential used to connect to this location.

  • comment

    An optional description for the location, or NULL. The default is NULL.

Examples

-- Create a location accessed using the abfss_remote_cred credential
> CREATE EXTERNAL LOCATION abfss_remote URL 'abfss://container@storageaccount.dfs.core.windows.net/location'
    WITH (STORAGE CREDENTIAL abfss_remote_cred)
    COMMENT 'Default source for Azure exernal data';

Note the backticks (` `) around the external location and storage credential names in the following example. Backticks are required for object names that include special characters, such as hyphens (-). Object names with underscores (_), such as those in the previous example, don’t require backticks. See Names.

-- Create a location accessed using the abfss_remote_cred credential
> CREATE EXTERNAL LOCATION `abfss-remote` URL 'abfss://container@storageaccount.dfs.core.windows.net/location'
    WITH (STORAGE CREDENTIAL `abfss-remote-cred`)
    COMMENT 'Default source for Azure exernal data';