DROP TABLE
DROP TABLE can be used to remove a table and all of its contents.
Permissions
The role must have the DDL permission on the table (or SUPERUSER on the table’s schema or database), and USAGE on the table’s schema. DDL granted at the database level does not satisfy this.
Syntax
drop_table_statement ::=
DROP TABLE [ IF EXISTS ] [schema_name.]table_name
;
table_name ::= identifier
schema_name ::= identifier
Parameters
Parameter |
Description |
|---|---|
|
Drop the table if it exists. Does not error if the table does not exist. |
|
The name of the schema from which to drop the table. |
|
The name of the table to drop. |
Examples
Dropping a table
DROP TABLE cool_animals;
Dropping a table (always succeeds)
farm=> DROP TABLE cool_animals;
executed
farm=> DROP TABLE cool_animals;
Table 'public.cool_animals' not found
-- This will succeed, even though the table does not exist
farm=> DROP TABLE IF EXISTS cool_animals;
executed