Skip to content

Instantly share code, notes, and snippets.

@KarateJB
Created March 2, 2020 05:02
Show Gist options
  • Save KarateJB/7bc8d5d3e2ce964adbdd4ce55a55b1a0 to your computer and use it in GitHub Desktop.
Save KarateJB/7bc8d5d3e2ce964adbdd4ce55a55b1a0 to your computer and use it in GitHub Desktop.
PostgreSQL SQL
SELECT
pg_terminate_backend(pid)
FROM
pg_stat_activity
WHERE
-- don't kill my own connection!
pid <> pg_backend_pid()
-- don't kill the connections to other databases
AND datname = 'my_database_name';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment