DROP TABLE

DROP TABLE — remove a table

Syntax

DROP TABLE 
    [IF EXISTS] [CASCADE | RESTRICT] [schema.]table_name
DROP TABLE 
    [schema.]table_name [IF EXISTS] [CASCADE | RESTRICT]

Description

Use the DROP TABLE statement to remove the table and all its data from the database entirely.
Only its owner may remove a table. A table may be emptied of rows, but not removed, by using DELETE. You can also use TRUNCATE. (See DELETE, TRUNCATE.)
DROP TABLE always removes any indexes, triggers, and constraints that exist for the target table. However, to drop a table that is referenced by a view CASCADE must be specified.
IF EXISTS, CASCADE and RESTRICT can occur before or after table_name, but not both.

Parameters

Example

USE HOCKEY
DROP TABLE hockey_fan;
 can't find table "HOCKEY_FAN"
DROP TABLE IF EXISTS hockey_fan;
 
CREATE TABLE hockey_fan (id     INTEGER GENERATED ALWAYS AS IDENTITY,
                         name   STRING );
 
CREATE VIEW vw_hockey_a AS SELECT * FROM hockey_fan WHERE name LIKE 'A%';
 
DROP TABLE hockey_fan;
can't drop table HOCKEY.HOCKEY_FAN -- referenced in view for HOCKEY.VW_HOCKEY_A
DROP TABLE hockey_fan CASCADE;