I have a script in PostgreSQL which restores test database from dump every night. The database is accessed by app servers and processes with connection pool which keeps a fe
I had a different usage scenario, in which I wanted to disable a DB for everyone (including superuser) and forever, but not plainly drop it just yet, to be able to reactivate it quickly if needed.
This worked fine on an old 8.3 Postgres:
UPDATE pg_database SET datallowconn=false WHERE datname='my_db_name';