Answer by Daniil Palii for How to drop a PostgreSQL database if there are...
On Windows, You can open the Task Manager -> Services, find the "postgresql" process, and restart it. When service will running again the database can be removed.
View ArticleAnswer by Ashburn RK for How to drop a PostgreSQL database if there are...
Nothing worked for me except, I loggined using pgAdmin4 and on the Dashboard I disconnected all connections except pgAdmin4 and then was able to rename by right lick on the database and properties and...
View ArticleAnswer by Lukasz Szozda for How to drop a PostgreSQL database if there are...
PostgreSQL 13 introduced FORCE option.DROP DATABASEDROP DATABASE drops a database ... Also, if anyone else is connected to the target database, this command will fail unless you use the FORCE option...
View ArticleAnswer by devdrc for How to drop a PostgreSQL database if there are active...
Easy Peasy.I just restart the service in Ubuntu to disconnect connected clients.sudo service postgresql stopsudo service postgresql startpsqlDROP DATABASE DB_NAME;
View ArticleAnswer by Eduardo Lucio for How to drop a PostgreSQL database if there are...
Here's my hack... =D# Make sure no one can connect to this database except you!sudo -u postgres /usr/pgsql-9.4/bin/psql -c "UPDATE pg_database SET datallowconn=false WHERE...
View ArticleAnswer by Chtiwi Malek for How to drop a PostgreSQL database if there are...
In my case i had to execute a command to drop all connections including my active administrator connectionSELECT pg_terminate_backend(pg_stat_activity.pid)FROM pg_stat_activityWHERE datname =...
View ArticleAnswer by Marcelo C. for How to drop a PostgreSQL database if there are...
PostgreSQL 9.2 and above:SELECT pg_terminate_backend(pid)FROM pg_stat_activity WHERE datname = 'YOUR_DATABASE_NAME_HERE'
View ArticleAnswer by Maurice Elagu for How to drop a PostgreSQL database if there are...
In Linux command Prompt, I would first stop all postgresql processes that are running by tying this commandsudo /etc/init.d/postgresql restarttype the command bg to check if other postgresql processes...
View ArticleAnswer by jb. for How to drop a PostgreSQL database if there are active...
Depending on your version of postgresql you might run into a bug, that makes pg_stat_activity to omit active connections from dropped users. These connections are also not shown inside pgAdminIII. If...
View ArticleAnswer by Craig Ringer for How to drop a PostgreSQL database if there are...
In PostgreSQL 9.2 and above, to disconnect everything except your session from the database you are connected to:SELECT pg_terminate_backend(pg_stat_activity.pid)FROM pg_stat_activityWHERE datname =...
View ArticleAnswer by kbrock for How to drop a PostgreSQL database if there are active...
I noticed that postgres 9.2 now calls the column pid rather than procpid.I tend to call it from the shell:#!/usr/bin/env bash# kill all connections to the postgres serverif [ -n "$1" ] ; then...
View ArticleAnswer by a_horse_with_no_name for How to drop a PostgreSQL database if there...
You could kill all connections before dropping the database using the pg_terminate_backend(int) function. You can get all running backends using the system view pg_stat_activityI'm not entirely sure,...
View ArticleAnswer by Kuberchaun for How to drop a PostgreSQL database if there are...
This will drop existing connections except for yours:Query pg_stat_activity and get the pid values you want to kill, then issue SELECT pg_terminate_backend(pid int) to them.PostgreSQL 9.2 and...
View ArticleHow to drop a PostgreSQL database if there are active connections to it?
I need to write a script that will drop a PostgreSQL database. There may be a lot of connections to it, but the script should ignore that.The standard DROP DATABASE db_name query doesn't work when...
View Article