Last active
May 9, 2018 19:44
-
-
Save prosoftwaredev/ae2050f464693b94c6f36e27b962423f to your computer and use it in GitHub Desktop.
How to drop a PostgreSQL database if there are active connections to it?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo -u postgres psql postgres | |
SELECT pg_terminate_backend(pg_stat_activity.pid) FROM pg_stat_activity WHERE pg_stat_activity.datname = 'DB NAME' AND pid <> pg_backend_pid(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment