Skip to content

Instantly share code, notes, and snippets.

@LuisSevillano
Created December 6, 2018 08:24
Show Gist options
  • Save LuisSevillano/17abd51669bb0c73151fddaf22b63be1 to your computer and use it in GitHub Desktop.
Save LuisSevillano/17abd51669bb0c73151fddaf22b63be1 to your computer and use it in GitHub Desktop.
Close all connections from a Postgres database
SELECT *, pg_terminate_backend(pid) FROM pg_stat_activity WHERE pid <> pg_backend_pid() AND datname = 'database';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment