Skip to content

Instantly share code, notes, and snippets.

@ganapathichidambaram
Last active November 11, 2019 09:08
Show Gist options
  • Save ganapathichidambaram/4fd0665563fbd07740e38a4472a7d707 to your computer and use it in GitHub Desktop.
Save ganapathichidambaram/4fd0665563fbd07740e38a4472a7d707 to your computer and use it in GitHub Desktop.
Kill Active Session of Postgresql DB
-- SQL : Postgresql
-- Query : Kill all the active connection of particular database.
SELECT
pg_terminate_backend(pid)
FROM
pg_stat_activity
WHERE
pid <> pg_backend_pid()
AND datname = 'dev'; -- dev- Database Name which connection needs to be terminate
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment