Skip to content

Instantly share code, notes, and snippets.

@andilabs
Created September 6, 2017 14:48
Show Gist options
  • Save andilabs/f5798684a578839c22f1270351c03c39 to your computer and use it in GitHub Desktop.
Save andilabs/f5798684a578839c22f1270351c03c39 to your computer and use it in GitHub Desktop.
kill all connections to postgres database
SELECT pg_terminate_backend(pg_stat_activity.pid)
FROM pg_stat_activity
WHERE pg_stat_activity.datname = 'YOUR_DATABASE_NAME'
AND pid <> pg_backend_pid();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment