Skip to content

Instantly share code, notes, and snippets.

@webevt
Created November 5, 2017 09:52
Show Gist options
  • Save webevt/e69b88c8e7a9958b8d0899b9ad43b418 to your computer and use it in GitHub Desktop.
Save webevt/e69b88c8e7a9958b8d0899b9ad43b418 to your computer and use it in GitHub Desktop.
Drop active connections for TARGET_DB in postgres
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