Last active
January 15, 2021 11:39
-
-
Save simonthompson99/a9fdbeda64a718de7e99445f36e86be8 to your computer and use it in GitHub Desktop.
[Close postgres connections] Terminate postgres connections to database #sql #database
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| select pg_terminate_backend(pg_stat_activity.pid) | |
| from pg_stat_activity | |
| where pg_stat_activity.datname = '<db_name>' -- ← change this to your db | |
| and pid <> pg_backend_pid() and usename = '<user>' | |
| ; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment