Skip to content

Instantly share code, notes, and snippets.

@bistaray
Created January 25, 2017 22:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bistaray/bda010949feb4f6b45636aa7bce6ae66 to your computer and use it in GitHub Desktop.
Save bistaray/bda010949feb4f6b45636aa7bce6ae66 to your computer and use it in GitHub Desktop.
Kill PostgreSQL sessions preventing a database from being dropped
SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE pid <> pg_backend_pid() AND datname = 'database_name';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment