PostgreSQL - Drop all tables in current DB
DO $$
DECLARE
tbl pg_tables%ROWTYPE;
BEGIN
FOR tbl IN SELECT * FROM pg_tables
WHERE schemaname = 'public'
LOOP
EXECUTE 'DROP TABLE ' || tbl.tablename || ' CASCADE;';
END LOOP;
END$$
Written by Stefan Nuxoll
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Postgresql
Authors
Related Tags
#postgresql
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#