Forked from gilyes/Kill connections to postgres database
Created
June 17, 2021 08:42
-
-
Save dgierejkiewicz/ae02749c4ed6a06f5dcf77f4403b9166 to your computer and use it in GitHub Desktop.
Kill connections to postgres database
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
SELECT pg_terminate_backend(pg_stat_activity.pid) | |
FROM pg_stat_activity | |
WHERE pg_stat_activity.datname = 'TARGET_DB' | |
AND pid <> pg_backend_pid(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment