How can I delete all tables in postgresql, working from the command line?
I don't want to drop the database itself - just all tables and all the data in them.
Thanks.
How can I delete all tables in postgresql, working from the command line?
I don't want to drop the database itself - just all tables and all the data in them.
Thanks.
You can write a query to generate a SQL script like this:
select 'drop table ' || tablename || ' cascade;' from pg_tables;
Or:
select 'drop table if exists ' || tablename || ' cascade;' from pg_tables;
In case some tables are automatically dropped due to cascade option in a previous sentence.
And then run it.
Glorious COPY+PASTE will also work.