Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SQL

postgres killing connections on db

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 = 'database_name'
    ;
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #postgres #killing #connections #db
ADD COMMENT
Topic
Name
2+2 =