Sometimes it can be useful to drop all tables of a schema directly, especially if you want to re-import a backup from another environment. It can be tedious to issue individual DROP TABLE statements; fortunately PostgreSQL schemas comply with the SQL standard. Unlike MySQL which mixes the concepts of database and schema, in PostgreSQL databases can contain several schemas. Generally we don’t pay attention to it, but you should know that by default the tables are in the public schema. We will leverage the PostgreSQL schema concept to perform this cleanup. To drop all tables of your schema, simply enter the following SQL commands:
DROP SCHEMA public CASCADE;
CREATE SCHEMA public;
The interest of the cascade keyword here is to resolve drops blocked by foreign keys. You now know how to drop all tables of a PostgreSQL schema simply.