Skip to content

Instantly share code, notes, and snippets.

@simonthompson99
Last active January 15, 2021 11:39
Show Gist options
  • Select an option

  • Save simonthompson99/a9fdbeda64a718de7e99445f36e86be8 to your computer and use it in GitHub Desktop.

Select an option

Save simonthompson99/a9fdbeda64a718de7e99445f36e86be8 to your computer and use it in GitHub Desktop.
[Close postgres connections] Terminate postgres connections to database #sql #database
select pg_terminate_backend(pg_stat_activity.pid)
from pg_stat_activity
where pg_stat_activity.datname = '<db_name>' -- ← change this to your db
and pid <> pg_backend_pid() and usename = '<user>'
;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment