Skip to content

DROP TABLE / DROP EXTERNAL TABLE

Use the DROP TABLE or DROP EXTERNAL TABLE commands to remove table definitions from the ScramDB catalog.

Syntax

For Internal Tables (created with CREATE TABLE):

DROP TABLE [IF EXISTS] table_name;

For External Tables (created with CREATE EXTERNAL TABLE):

DROP EXTERNAL TABLE [IF EXISTS] table_name;
  • DROP TABLE: Used specifically for internal tables stored in Tundra. Attempting to use this on an external table will result in an error. This command removes the table definition and deletes the associated data from the internal storage.
  • DROP EXTERNAL TABLE: Used specifically for external tables. Attempting to use this on an internal table will result in an error. This command only removes the table definition (metadata) from ScramDB’s catalog; it does not delete the underlying external data files specified in the LOCATION clause.
  • IF EXISTS: (Optional) Prevents an error if the specified table does not exist.
  • table_name: The name of the table to drop.

Important Distinction

It is crucial to use the correct command based on the table type:

  • Use DROP TABLE for internal tables.
  • Use DROP EXTERNAL TABLE for external tables.

Using the wrong command will result in an error due to the strict separation policy enforced by the Catalog Manager.

Examples

-- Drop an internal table named 'users'
DROP TABLE IF EXISTS users;
-- Drop an external table named 'orders_parquet'
DROP EXTERNAL TABLE IF EXISTS orders_parquet;