Skip to content

Instantly share code, notes, and snippets.

@giansalex
Created March 20, 2018 15:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save giansalex/9e22ac103d9a1c80a403f40b3018291d to your computer and use it in GitHub Desktop.
Save giansalex/9e22ac103d9a1c80a403f40b3018291d to your computer and use it in GitHub Desktop.
SELECT
pg_terminate_backend(procpid)
FROM
pg_stat_activity
WHERE
-- don't kill my own connection!
procpid <> pg_backend_pid()
-- don't kill the connections to other databases
AND datname = 'database_name'
;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment