Created
September 18, 2018 09:37
-
-
Save ichux/b882a9cccf0eb21bbf6b87c8fc7c2913 to your computer and use it in GitHub Desktop.
Drop DB in Postgres
This file contains 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
-- Terminate any existing connections to `thedb` | |
SELECT | |
pg_terminate_backend(pg_stat_activity.pid) | |
FROM | |
pg_stat_activity | |
WHERE | |
pg_stat_activity.datname = 'thedb' | |
AND pid <> pg_backend_pid(); | |
-- Now go ahead and drop the database, `thedb` | |
DROP DATABASE thedb; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment