Created
March 6, 2014 15:54
-
-
Save joaquinmoreira/9392764 to your computer and use it in GitHub Desktop.
Close opened connections to postgresql
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
REVOKE CONNECT ON DATABASE dbname FROM PUBLIC, <username>; -- Prevent from accepting new connections | |
SELECT pg_terminate_backend(pid) | |
FROM pg_stat_activity | |
WHERE pid <> pg_backend_pid() -- Don't kill my own connection! | |
AND datname = <database>; -- Don't kill the connections to other databases |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment