---
title: CREATE EXTERNAL LOCATION
description: Create an external location that references cloud storage with CREATE EXTERNAL LOCATION in Databricks SQL and Databricks Runtime.
canonical_url: https://docs.databricks.com/aws/en/sql/language-manual/sql-ref-syntax-ddl-create-location
---

# CREATE EXTERNAL LOCATION

**Applies to:** ![check marked yes](https://docs.databricks.com/aws/en/images/icons/check.png) Databricks SQL ![check marked yes](https://docs.databricks.com/aws/en/images/icons/check.png) Databricks Runtime 10.4 LTS and above ![check marked yes](https://docs.databricks.com/aws/en/images/icons/check.png) 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 [ Option 2: Create an external location using SQL](https://docs.databricks.com/aws/en/connect/unity-catalog/cloud-storage/s3/s3-external-location-manual.md#sql).

## Permissions

To create an external location, you must be a metastore admin or have the `CREATE EXTERNAL LOCATION` privilege on the metastore. You must also have the `CREATE EXTERNAL LOCATION` privilege on the storage credential used by the location.

## 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](https://docs.databricks.com/aws/en/sql/language-manual/sql-ref-names.md) and [Examples](https://docs.databricks.com/aws/en/sql/language-manual/sql-ref-syntax-ddl-create-location.md#example).

## Parameters

* **[location\_name](https://docs.databricks.com/aws/en/sql/language-manual/sql-ref-names.md#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](https://docs.databricks.com/aws/en/sql/language-manual/sql-ref-names.md#credential-name)**

  The named credential used to connect to this location.

* **comment**

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

## <a id="example" />Examples

```sql
-- Create a location accessed using the s3_remote_cred credential
> CREATE EXTERNAL LOCATION s3_remote URL 's3://us-east-1/location'
     WITH (STORAGE CREDENTIAL s3_remote_cred)
     COMMENT 'Default source for AWS 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](https://docs.databricks.com/aws/en/sql/language-manual/sql-ref-names.md).

```sql
-- Create a location accessed using the s3_remote_cred credential
> CREATE EXTERNAL LOCATION `s3-remote` URL 's3://us-east-1/location'
     WITH (STORAGE CREDENTIAL `s3-remote-cred`)
     COMMENT 'Default source for AWS exernal data';
```

## Related articles

* [ALTER EXTERNAL LOCATION](https://docs.databricks.com/aws/en/sql/language-manual/sql-ref-syntax-ddl-alter-location.md)
* [DESCRIBE EXTERNAL LOCATION](https://docs.databricks.com/aws/en/sql/language-manual/sql-ref-syntax-aux-describe-location.md)
* [DROP EXTERNAL LOCATION](https://docs.databricks.com/aws/en/sql/language-manual/sql-ref-syntax-ddl-drop-location.md)
* [External locations and storage credentials](https://docs.databricks.com/aws/en/sql/language-manual/sql-ref-external-locations.md)
* [SHOW EXTERNAL LOCATIONS](https://docs.databricks.com/aws/en/sql/language-manual/sql-ref-syntax-aux-show-locations.md)
