ALTER EXTERNAL TABLE

statementsupportedIceberg & external tables

docs.snowflake.com ↗

Object: EXTERNAL TABLE

Modifies the properties, columns, or constraints for an existing external table.

Syntax

supportedpartialnot supportednot scored

ALTER EXTERNAL TABLE [ IF EXISTS ] <name> REFRESH [ '<relative-path>' ]

ALTER EXTERNAL TABLE [ IF EXISTS ] <name> ADD FILES ( '<path>/[<filename>]' [ , '<path>/[<filename>'] ] )

ALTER EXTERNAL TABLE [ IF EXISTS ] <name> REMOVE FILES ( '<path>/[<filename>]' [ , '<path>/[<filename>]' ] )

ALTER EXTERNAL TABLE [ IF EXISTS ] <name> SET
  [ AUTO_REFRESH = { TRUE | FALSE } ]

Partitions added and removed manually

ALTER EXTERNAL TABLE <name> [ IF EXISTS ] ADD PARTITION ( <part_col_name> = '<string>' [ , <part_col_name> = '<string>' ] ) LOCATION '<path>'

ALTER EXTERNAL TABLE <name> [ IF EXISTS ] DROP PARTITION LOCATION '<path>'

Parameters

NameRequiredDescription
nameIdentifier for the external table to alter. If the identifier contains spaces or special characters, the entire string must be enclosed in double quotes. Identifiers enclosed in double quotes are also case sensitive.
REFRESH [ 'relative-path' ]Accesses the staged data files referenced in the external table definition and updates the table metadata: New files in the path are added to the table metadata. Changes to files in the path are updated in the table metadata. Files no longer in the path are removed from the table metadata. Optionally specify a relative path to refresh the metadata for a specific subset of the data files. Using this parameter only needs to be done once, when the external table is created. This step synchronizes the metadata with the latest set of associated files in the stage and path in the external table definition. Also, this step ensures the external table can read the data files in the specified stage and path, and that no files were missed in the external table definition. Note This parameter isn’t supported by partitioned external tables when partitions are added manually by the object owner; that is, when PARTITION_TYPE = USER_SPECIFIED. If TABLE_FORMAT = DELTA is set on the external table, REFRESH doesn’t support a relative path to refresh the metadata for a specific subset of the data files.
ADD FILESRegisters the specified comma-separated list of files with the external table metadata, and refreshes the table. For each file, list the path and filename relative to [ WITH ] LOCATION in the external table definition. For information, see CREATE EXTERNAL TABLE. This parameter is not supported by partitioned external tables when partitions are added manually by the object owner; that is, when PARTITION_TYPE = USER_SPECIFIED.
REMOVE FILESDeregisters the specified comma-separated list of files from the external table metadata, and refreshes the table. For each file, list the path and filename relative to [ WITH ] LOCATION in the external table definition. For more information, see CREATE EXTERNAL TABLE. This parameter is not supported by partitioned external tables when partitions are added manually by the object owner; that is, when PARTITION_TYPE = USER_SPECIFIED.
SET ...Specifies one or more properties/parameters to set for the external table that is separated by blank spaces, commas, or new lines:
AUTO_REFRESH = { TRUE | FALSE }Specifies whether Snowflake should enable triggering automatic refreshes of the external table metadata when new or updated data files are available in the named external stage specified in the [ WITH ] LOCATION = setting. Note Amazon S3: Refresh external tables automatically for Amazon S3 Google Cloud Storage: Refresh external tables automatically for Google Cloud Storage Microsoft Azure: Refresh external tables automatically for Azure Blob Storage This parameter isn’t supported by partitioned external tables when partitions are added manually by the object owner; that is, when PARTITION_TYPE = USER_SPECIFIED. Setting this parameter to TRUE isn’t supported for external tables that reference data files stored on an S3-compatible external stage. Default: TRUE
  • TRUE — Snowflake enables the triggering of automatic refreshes of the external table metadata.
  • FALSE — Snowflake doesn’t enable the triggering of automatic refreshes of the external table metadata. You must manually refresh the external table metadata periodically by using ALTER EXTERNAL TABLE … REFRESH to synchronize the metadata with the current list of files in the stage path.
ADD PARTITION ( <part_col_name> = '<string>' [ , <part_col_name> = '<string>' , ... ] ) LOCATION '<path>'Manually add a partition for one or more partition columns defined for the external table in a specified location; that is, path. Note The maximum length of user-specified partition column names is 32 characters. Adding a partition also adds any new or updated files in the location to the external table metadata.
DROP PARTITION LOCATION '<path>'Manually drop all partitions in a specified location; that is, path. Dropping a partition also removes any files in the location from the external table metadata.

Usage notes

Access control requirements

A role used to execute this operation must have the following privileges at a minimum: Privilege | Object | Notes OWNERSHIP | External table | OWNERSHIP is a special privilege on an object that is automatically granted to the role that created the object, but can also be transferred using the GRANT OWNERSHIP command to a different role by the owning role (or any role with the MANAGE GRANTS privilege). USAGE | Stage | Required to manually refresh the external table metadata. USAGE | File format | Required to manually refresh the external table metadata. Operating on an object in a schema requires at least one privilege on the parent database and at least one privilege on the parent schema. For instructions on creating a custom role with a specified set of privileges, see Creating custom roles. For general information about roles and privilege grants for performing SQL actions on securable objects, see Overview of Access Control.

See also

Referenced by