Skip to content

Instantly share code, notes, and snippets.

@csokun
Created September 10, 2023 09:18
Show Gist options
  • Save csokun/efc5313e28d1dc23c60522460555fa50 to your computer and use it in GitHub Desktop.
Save csokun/efc5313e28d1dc23c60522460555fa50 to your computer and use it in GitHub Desktop.
postgres disconnect all clients
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