Drop all Tables in PostgreSQL

From SQL Query Editor:

DROP SCHEMA public CASCADE;
CREATE SCHEMA public;

You also need to run some grants to interact with the database:

GRANT ALL ON SCHEMA public TO postgres;
GRANT ALL ON SCHEMA public TO public;
COMMENT ON SCHEMA public IS 'standard public schema’;

If you don’t want to recreate the schema and restore the default grants:

DO $$ DECLARE
    r RECORD;
BEGIN
    FOR r IN (SELECT tablename FROM pg_tables WHERE schemaname = current_schema()) LOOP
        EXECUTE 'DROP TABLE IF EXISTS ' || quote_ident(r.tablename) || ' CASCADE';
    END LOOP;
END $$;

From TablePlus PostgreSQL GUI:

You can select all the available tables from the right panel (cmd + A) and hit delete to drop all. Don’t forget to commit changes to the server (cmd + S) after doing so.

Drop all tables in TablePlus


Need a good GUI Tool for PostgreSQL? Check out TablePlus, a modern, native client for relational databases. It’s also free!