Skip to content

Instantly share code, notes, and snippets.

@ryanpadilha
Created August 7, 2017 22:29
Show Gist options
  • Save ryanpadilha/3df07d3e35237204d316c4f37a227638 to your computer and use it in GitHub Desktop.
Save ryanpadilha/3df07d3e35237204d316c4f37a227638 to your computer and use it in GitHub Desktop.
Drop all connections to a specific database-name
-- PostgreSQL 9.6
-- view connections
select * from pg_stat_activity where datname = 'db_name';
-- drop connections
select pg_terminate_backend(pid) from pg_stat_activity where datname = 'db_name';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment