Have you ever seen this error message when you are trying to delete particular DB ?
This error message tells us that DB in used and cannot be dropped. And sometimes I feel little bit annoying because I don’t have much time to ask anyone who access / remote DB to close their connection. So what I am going to say is I will force drop db by killing active session. Here is the SQL Script to kill their active session
SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE pg_stat_activity.datname = 'DB_NAME' AND pid <> pg_backend_pid();