Postgresql – Drop connections script

Select another database in pgadmin and execute this script to drop all connected users.

Script

-- view active connections
select * from pg_stat_activity where datname='DBNAME';
-- drop active connections
select pg_terminate_backend(procpid) from pg_stat_activity where datname='DBNAME';