SQL Keywords

SQL EXTERNAL

What is the SQL EXTERNAL keyword?

Denotes objects that reside outside the local database, most commonly in CREATE EXTERNAL TABLE or CREATE EXTERNAL DATA SOURCE statements.
Sign up to get up to date news on SQL keywords
Welcome to the Galaxy, Guardian!
You'll be receiving a confirmation email

Follow us on twitter :)
Oops! Something went wrong while submitting the form.

Compatible dialects for SQL EXTERNAL: SQL Server (PolyBase and Azure Synapse), Oracle (ORGANIZATION EXTERNAL), Snowflake, Google BigQuery, Amazon Redshift Spectrum, Hive, Databricks Spark SQL

SQL EXTERNAL Full Explanation

EXTERNAL is a reserved keyword used by several SQL dialects to declare and interact with data or code that lives outside the database engine. In Microsoft SQL Server PolyBase, Snowflake, Oracle, BigQuery and other platforms, EXTERNAL appears in DDL commands to create external tables, file formats, and data sources that map to cloud storage, HDFS, or on-prem files. These objects are read-only (or append-only, depending on the platform) and let you query external data with regular SQL.Because EXTERNAL is not a standalone statement but part of larger CREATE or ALTER commands, its behavior depends on the surrounding clause. Common patterns include:- CREATE EXTERNAL TABLE – defines a table whose data is stored in external files.- CREATE EXTERNAL DATA SOURCE – registers the location and access credentials of the remote storage system.- CREATE EXTERNAL FILE FORMAT – describes how to parse the external files (CSV, Parquet, JSON, etc.).Caveats:- External tables often do not support DML (INSERT, UPDATE, DELETE).- Performance is limited by the underlying storage throughput.- Permissions must allow the database engine to reach the external location.

SQL EXTERNAL Syntax

-- Register the storage
CREATE EXTERNAL DATA SOURCE <data_source_name>
WITH (
    TYPE = HADOOP | BLOB_STORAGE | RDBMS,
    LOCATION = '<protocol>://<path>',
    CREDENTIAL = <credential_name>
);

-- Define file format
CREATE EXTERNAL FILE FORMAT <format_name>
WITH (
    FORMAT_TYPE = DELIMITEDTEXT | PARQUET | ORC,
    ...
);

-- Create external table
CREATE EXTERNAL TABLE <schema.table_name> (
    <column_definitions>
)
WITH (
    LOCATION = '<folder_or_file_path>',
    DATA_SOURCE = <data_source_name>,
    FILE_FORMAT = <format_name>
);

SQL EXTERNAL Parameters

Example Queries Using SQL EXTERNAL

-- 1. Create an external data source that points to Azure Blob Storage
CREATE EXTERNAL DATA SOURCE SalesBlob
WITH (
    TYPE = BLOB_STORAGE,
    LOCATION = 'wasbs://sales@myblob.blob.core.windows.net/',
    CREDENTIAL = SalesBlobCred
);

-- 2. Define a CSV file format
CREATE EXTERNAL FILE FORMAT CsvFormat
WITH (
    FORMAT_TYPE = DELIMITEDTEXT,
    FORMAT_OPTIONS (
        FIELD_TERMINATOR = ',',
        STRING_DELIMITER = '"'
    )
);

-- 3. Create an external table over the 2024 sales folder
CREATE EXTERNAL TABLE dbo.Sales_2024 (
    OrderID   INT,
    OrderDate DATE,
    Amount    DECIMAL(10,2)
)
WITH (
    LOCATION = '/2024/',
    DATA_SOURCE = SalesBlob,
    FILE_FORMAT = CsvFormat
);

-- 4. Query the external table like any other
SELECT TOP 10 * FROM dbo.Sales_2024;

Expected Output Using SQL EXTERNAL

  • Steps 1–3 register the external location, format, and table without moving data into the database
  • Step 4 returns the first 10 rows from the CSV files stored in Azure Blob Storage

Use Cases with SQL EXTERNAL

  • Ad-hoc analysis of large CSV or Parquet files in cloud storage without loading them
  • Staging data for ETL jobs where the raw files remain in object storage
  • Federating queries across on-prem and cloud data sources
  • Cost-effective analytics on infrequently accessed data (data lakehouse patterns)

Common Mistakes with SQL EXTERNAL

  • Assuming external tables support INSERT/UPDATE/DELETE; most are read-only
  • Forgetting to grant data-engine access to the external location, leading to runtime errors
  • Mismatch between column definitions and file format, causing type conversion failures
  • Omitting FILE_FORMAT or DATA_SOURCE clauses
  • Attempting to use features like indexes or constraints that are not supported on external tables

Related Topics

CREATE EXTERNAL TABLE, CREATE EXTERNAL DATA SOURCE, CREATE EXTERNAL FILE FORMAT, FOREIGN TABLE, FDW, BULK INSERT

First Introduced In

Oracle 9i external tables (2001); adopted by SQL Server 2016 PolyBase

Frequently Asked Questions

What is SQL EXTERNAL?

EXTERNAL is a reserved SQL keyword used in CREATE statements to define objects that reference data or code stored outside the database engine, such as external tables and data sources.

Can I modify data in an external table?

In most implementations external tables are read-only. You can query them with SELECT but cannot run INSERT, UPDATE, or DELETE unless the database explicitly enables write support.

Is EXTERNAL part of the ANSI SQL standard?

No. EXTERNAL is vendor-specific. Oracle, SQL Server, Snowflake, BigQuery, and other platforms adopted it independently, so syntax and capabilities differ.

How do I speed up external table queries?

Store data in columnar formats like Parquet, partition files by high-cardinality columns, and locate the external data in the same region as the compute engine to minimize latency.

Sign up to get up to date news on SQL keywords
Welcome to the Galaxy, Guardian!
You'll be receiving a confirmation email

Follow us on twitter :)
Oops! Something went wrong while submitting the form.
Trusted by top engineers on high-velocity teams
Aryeo Logo
Assort Health
Curri
Rubie Logo
Bauhealth Logo
Truvideo Logo

Check out other commonly used SQL Keywords!