Chris Straw
SHARE:

PostgreSQL: Terminating all active connections and dropping the database

Drop all active connections.

Run this script to drop all active connections.

SELECT  pg_terminate_backend (pg_stat_activity.pid) FROM  pg_stat_activity WHERE  pg_stat_activity.datname = 'DatabaseName';

Drop Database.

DROP DATABASE "DatabaseName";