Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
killing postgresql sessions
-- this query kills any active session attached to the 'dbname' database, which can prevent you from
-- running certain administrative operations on the database
select pg_terminate_backend(pid)
from pg_stat_activity
where pid IN (select pid from pg_stat_activity where datname = 'dbname');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment