Skip to content

Instantly share code, notes, and snippets.

@aypn0s
Created June 3, 2020 08:10
Show Gist options
  • Select an option

  • Save aypn0s/45c345545f575ef09a0acc0a8ea9225a to your computer and use it in GitHub Desktop.

Select an option

Save aypn0s/45c345545f575ef09a0acc0a8ea9225a to your computer and use it in GitHub Desktop.
terminate postgresql sessions on database
SELECT pg_terminate_backend(pg_stat_activity.pid)
FROM pg_stat_activity
WHERE pg_stat_activity.datname = 'db_name'
AND pid <> pg_backend_pid();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment