Answer the question
In order to leave comments, you need to log in
How to delete database in postgres without paying attention to active sessions?
Actually, subject. Hanging sessions prevent the database from being deleted.
Answer the question
In order to leave comments, you need to log in
Preventing new connections
Close current sessions
SELECT pg_terminate_backend(pg_stat_activity.pid)
FROM pg_stat_activity
WHERE pg_stat_activity.datname = 'database_name' AND pid <> pg_backend_pid();
DROP DATABASE database_name;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question