13

I'm sending queries through Django on a PaaS service, and I think I can't access any command line utilities. I would have just dropped the entire database and recreated it, but I don't have permissions for that.

I'm looking for a simple command that would return the database to a completely virgin state.

2

1 Answer 1

12

you could cascade drop the schema and then drop the db:

drop schema myschema CASCADE;
drop database mydb;

if you do not have the rights to do so, you will have to drop table by table.

EDIT: If you can only drop tables, this will give you the SQL statements to run:

select 'drop table '||schemaname||'.'||tablename||' CASCADE;' 
from pg_tables where schemaname = 'myschema' order by schemaname, tablename;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.