DROP EXTERNAL TABLE
statementsupportedIceberg & external tablesRemoves an external table from the current or specified schema. This is a metadata-only operation. None of the files that the external table refers to are dropped.
Syntax
supportedpartialnot supportednot scored
DROP EXTERNAL TABLE [ IF EXISTS ] <name> [ CASCADE | RESTRICT ]
Parameters
| Name | Required | Description |
|---|---|---|
name | Specifies the identifier for the external table to drop. If the identifier contains spaces, special characters, or mixed-case characters, the entire string must be enclosed in double quotes. Identifiers enclosed in double quotes are also case sensitive; for example, "My Object". If the external table identifier is not fully qualified, in the form of db_name.schema_name.table_name or schema_name.table_name, the command looks for the external table in the current schema for the session. | |
CASCADE | RESTRICT | Specifies whether the external table can be dropped if foreign keys exist that reference the table: CASCADE drops the external table even if it has primary or unique keys that are referenced by foreign keys in other tables. RESTRICT returns a warning about existing foreign key references and doesn’t drop the external table. Default: CASCADE |
Usage notes
- Unlike a standard table, dropping an external table purges it from the system. An external table can’t be recovered by using Time Travel; also, there is no UNDROP EXTERNAL TABLE command. A dropped external table must be recreated.
- After dropping an external table, creating an external table with the same name recreates the table. No history from the old version of the external table is retained.
- Before dropping an external table, verify that no views reference the table. Dropping an external table referenced by a view invalidates the view; that is, querying the view returns an “object does not exist” error.
- When the IF EXISTS clause is specified and the target object doesn’t exist, the command completes successfully without returning an error.