Skip to content

Instantly share code, notes, and snippets.

@dradford
Created May 1, 2014 07:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dradford/7d5bf17b57e8a7b37d04 to your computer and use it in GitHub Desktop.
Save dradford/7d5bf17b57e8a7b37d04 to your computer and use it in GitHub Desktop.
Drop DB Connections
REVOKE CONNECT ON DATABASE dbname FROM PUBLIC, username;
SELECT
pg_terminate_backend(pid)
FROM
pg_stat_activity
WHERE
-- don't kill my own connection!
pid <> pg_backend_pid()
-- don't kill the connections to other databases
AND datname = 'bugcrowd_portal_development'
;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment