Skip to content

Instantly share code, notes, and snippets.

@gilyes
Created June 16, 2016 04:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save gilyes/74fc87c6672292ff976e7369fab7ffcf to your computer and use it in GitHub Desktop.
Save gilyes/74fc87c6672292ff976e7369fab7ffcf to your computer and use it in GitHub Desktop.
Kill connections to postgres database
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