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.
Unix. The default directory for PostgreSQL is /usr/local/pgsql. To uninstall PostgreSQL, manually delete the PostgreSQL folder from the default directory. To delete the database files, manually delete the Data folder from the default directory.
But there is another way in pgAdmin4: Close connections to the databases you would like to delete by right-clicking on it and selecting "Disconnect database..." Left-click on "Databases" (One up in the hierarchy: The folder that contains all your databases) Select tab "Properties" on the right hand side.
By using fetching all table names from pg_tables table. PostgreSQL stores all the tables on its record table named pg_table . SELECT 'DROP TABLE IF EXISTS "' || tablename || '" CASCADE;' from pg_tables WHERE schemaname = 'public'; As you can see, By the use of subquery, We can remove the entire tables from the schema.
Using memory purge configuration parameters, Postgres Pro Standard can automatically replace data with zero bytes before it is deleted. This section describes how different types of data are handled. By default, all the memory purge parameters are switched on.
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;
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