---
title: External tables
description: External tables are Unity Catalog tables whose data lives in a cloud storage location you manage, in Databricks SQL and Databricks Runtime.
canonical_url: https://docs.databricks.com/aws/en/sql/language-manual/sql-ref-external-tables
---

# External tables

**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

Unity Catalog and the built-in Databricks Hive metastore use default locations for managed tables. Unity Catalog introduces several new securable objects to grant privileges to data in cloud object storage.

* **[storage credential](https://docs.databricks.com/aws/en/sql/language-manual/sql-ref-storage-credentials.md)**

  A Unity Catalog object used to abstract long term credentials from cloud storage providers.

* **[external location](https://docs.databricks.com/aws/en/sql/language-manual/sql-ref-external-locations.md)**

  A Unity Catalog object used to associate a cloud object storage URI with a [storage credential](https://docs.databricks.com/aws/en/sql/language-manual/sql-ref-storage-credentials.md).

* **[external table](https://docs.databricks.com/aws/en/sql/language-manual/sql-ref-external-tables.md#)**

  A Unity Catalog [table](https://docs.databricks.com/aws/en/sql/language-manual/sql-ref-syntax-ddl-create-table-using.md) created in a Unity Catalog-managed [external location](https://docs.databricks.com/aws/en/sql/language-manual/sql-ref-external-locations.md).

## External table

An external table is a [table](https://docs.databricks.com/aws/en/sql/language-manual/sql-ref-syntax-ddl-create-table-using.md) that references an external storage path by using a `LOCATION` clause.

The storage path should be contained in an existing [external location](https://docs.databricks.com/aws/en/sql/language-manual/sql-ref-external-locations.md) to which you have been granted access.

Alternatively you can reference a [storage credential](https://docs.databricks.com/aws/en/sql/language-manual/sql-ref-storage-credentials.md) to which you have been granted access.

Using external tables abstracts away the storage path, external location, and storage credential for users who are granted access to the external table.

> [!WARNING]
>
> If a schema (database) is registered in your workspace-level Hive metastore, dropping that schema using the `CASCADE` option causes all files in that schema location to be deleted recursively, regardless of the table type (managed or external).
>
> If the schema is registered to a Unity Catalog metastore, the files for Unity Catalog [managed tables](https://docs.databricks.com/aws/en/tables/managed.md) are deleted recursively. However, the files for [external tables](https://docs.databricks.com/aws/en/tables/external.md) are not deleted. You must manage those files using the cloud storage provider directly.
>
> Therefore, to avoid accidental data loss, you should never register a schema in a Hive metastore to a location with existing data. Nor should you create new external tables in a location managed by Hive metastore schemas or containing Unity Catalog managed tables.

## Graphical Representation of relationships

The following diagram describes the relationship between:

* storage credentials
* external locations
* external tables
* storage paths
* IAM entities
* Azure service accounts

![External location ER diagram](https://docs.databricks.com/aws/en/images/sql/external-location-er-diagram.png)

## Examples

```sql
-- `finance` can create an external table over specific object within the `finance_loc` location
> CREATE TABLE sec_filings LOCATION 's3://depts/finance/sec_filings';

-- Create or replace an external table from a query
> CREATE OR REPLACE TABLE sec_filings
  LOCATION 's3://depts/finance/sec_filings'
  AS (SELECT * FROM current_filings);

-- Cannot list files under an external table without permissions on it
> LIST `s3://depts/finance/sec_filings`
  Error
> LIST `s3://depts/finance/sec_filings/_delta_log`
  Error

-- Grant access to sec_filings to all employees
> GRANT SELECT ON TABLE sec_filings TO employee;

-- Any member of the `employee` group can securely read sec_filings
> SELECT count(1) FROM sec_filings;
 20

-- Any member of the `employee` group can list files under the sec_filings table
> LIST `s3://depts/finance/sec_filings`
  _delta_log
> LIST `s3://depts/finance/sec_filings/_delta_log`
  00000.json
```

## Related articles

* [Credentials](https://docs.databricks.com/aws/en/sql/language-manual/sql-ref-storage-credentials.md)
* [ALTER STORAGE CREDENTIAL](https://docs.databricks.com/aws/en/sql/language-manual/sql-ref-syntax-ddl-alter-credential.md)
* [ALTER TABLE](https://docs.databricks.com/aws/en/sql/language-manual/sql-ref-syntax-ddl-alter-table.md)
* [CREATE LOCATION](https://docs.databricks.com/aws/en/sql/language-manual/sql-ref-syntax-ddl-create-location.md)
* [DESCRIBE STORAGE CREDENTIAL](https://docs.databricks.com/aws/en/sql/language-manual/sql-ref-syntax-aux-describe-credential.md)
* [DESCRIBE TABLE](https://docs.databricks.com/aws/en/sql/language-manual/sql-ref-syntax-aux-describe-table.md)
* [DROP STORAGE CREDENTIAL](https://docs.databricks.com/aws/en/sql/language-manual/sql-ref-syntax-ddl-drop-credential.md)
* [DROP TABLE](https://docs.databricks.com/aws/en/sql/language-manual/sql-ref-syntax-ddl-drop-table.md)
* [SHOW STORAGE CREDENTIALS](https://docs.databricks.com/aws/en/sql/language-manual/sql-ref-syntax-aux-show-credentials.md)
* [SHOW TABLES](https://docs.databricks.com/aws/en/sql/language-manual/sql-ref-syntax-aux-show-tables.md)
* [GRANT](https://docs.databricks.com/aws/en/sql/language-manual/security-grant.md)
* [REVOKE](https://docs.databricks.com/aws/en/sql/language-manual/security-revoke.md)
