Created
December 21, 2021 02:51
-
-
Save ahelord/f241d837df1733db7e8d08b7ed3e0d80 to your computer and use it in GitHub Desktop.
Kill transaction postgres
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 * FROM pg_stat_activity WHERE state = 'active'; | |
SELECT pg_terminate_backend(pid) | |
FROM pg_stat_activity | |
WHERE -- don't kill my own connection! | |
pid <> pg_backend_pid() -- don't kill the connections to other databases | |
AND datname = 'postgres' | |
commit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment