Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

PostgreSQL : Drop all tables in a schema

PostgreSQL : Drop all tables in a schema



  • Drop & Create The schema
DROP SCHEMA CASCADE;
CREATE SCHEMA ;

  • Selectively Delete the tables
SELECT
    'drop table if exists "' || tablename || '" cascade;' as pg_drop
FROM
    pg_tables
WHERE
    schemaname= ;

    References

    01. https://stackoverflow.com/questions/3327312/drop-all-tables-in-postgresql
    02. https://skyvia.com/gallery/drop-all-tables-in-postgresql



    This post first appeared on Devdummy, please read the originial post: here

    Share the post

    PostgreSQL : Drop all tables in a schema

    ×

    Subscribe to Devdummy

    Get updates delivered right to your inbox!

    Thank you for your subscription

    ×