I would be interested to drop all tables in a Redshift schema. Even though this solution works
DROP SCHEMA public CASCADE; CREATE SCHEMA public; is NOT good for me since that it drops SCHEMA permissions as well.
A solution like
DO $$ DECLARE r RECORD; BEGIN -- if the schema you operate on is not "current", you will want to -- replace current_schema() in query with 'schematodeletetablesfrom' -- *and* update the generate 'DROP...' accordingly. 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 $$; as reported in this thread How can I drop all the tables in a PostgreSQL database? would be ideal. Unfortunately it doesn't work on Redshift (apparently there is no support for for loops).
Is there any other solution to achieve it?