Postgresql – Drop connections script

Select another database in pgadmin and execute this script to drop all connected users.

Script

-- view active connections
SELECT * FROM pg_stat_activity WHERE datname='DBNAME';
-- drop active connections
SELECT pg_terminate_backend(procpid) FROM pg_stat_activity WHERE datname='DBNAME';

admin

Chris Grgich-Tran is a Development Manager from Brisbane, Australia. When he's not dad-ing it up, he works with some very talented people.

More Posts

Follow Me:
TwitterFacebookLinkedInGoogle PlusFlickrYouTube

Comments