The DROP
statement removes database objects such as tables and schemas from the database.
DROP SCHEMA [ IF EXISTS ] schema_name
DROP TABLE [ IF EXISTS ] [ schema_name. ] table_name
Where:
IF EXISTS
: Prevents an error if the object does not existschema_name
: The name of the schema containing the objecttable_name
: The name of the table to dropDrop a schema if it exists:
DROP SCHEMA IF EXISTS my_schema;
Drop a table:
DROP TABLE my_table;
Drop a table in a specific schema:
DROP TABLE my_schema.my_table;
Drop a table only if it exists:
DROP TABLE IF EXISTS my_table;