Skip to content

Instantly share code, notes, and snippets.

@isccarrasco
Last active August 16, 2016 17:48
Show Gist options
  • Save isccarrasco/4072bd2ef1276948fce5 to your computer and use it in GitHub Desktop.
Save isccarrasco/4072bd2ef1276948fce5 to your computer and use it in GitHub Desktop.
Disconnect User from a database on PostgreSQL.

SELECT pg_terminate_backend(pg_stat_activity.pid) FROM pg_stat_activity WHERE pg_stat_activity.datname = 'TARGET_DB' AND pid <> pg_backend_pid();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment