Skip to content

Instantly share code, notes, and snippets.

@dibayendu
Created September 26, 2014 07:48
Show Gist options
  • Save dibayendu/fae77729092753e39941 to your computer and use it in GitHub Desktop.
Save dibayendu/fae77729092753e39941 to your computer and use it in GitHub Desktop.
Postgres remove connection of active users
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