I tried this ..
select 'drop table if exists "' || tablename || '" cascade;'
from pg_tables
where schemaname = 'public';
but doesn't seems to work out for one command?
How to drop all tables in PostgreSQL? 2 From TablePlus GUI: You can select all the available tables from the right sidebar, right click and choose Delete.. , or press Delete key to drop all. Don't forget to commit changes to the server (Cmd + S) after doing so.
First, specify the table from which you want to delete data in the DELETE FROM clause. Second, specify which rows to delete by using the condition in the WHERE clause. The WHERE clause is optional. However, if you omit it, the DELETE statement will delete all rows in the table.
PostgreSQL has a DROP TABLE statement that is used to remove an existing table or tables from the database. Syntax: DROP TABLE [IF EXISTS] table_name [CASCADE | RESTRICT]; Let's analyze the above syntax: We specify the table name after the DROP TABLE keyword to remove the table permanently from the database.
If all of your tables are in a single schema, this approach could work (below code assumes that the name of your schema is 'public')
drop schema public cascade;
create schema public;
Drop all tables in PostgreSQL?
see above link for more answers
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With