SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE datname = 'dbname';
postgres=# SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE datname = 'epsdb';drop database epsdb; pg_terminate_backend---------------------- t t t t(4 rows)* need to run both command in one script to avoid new session created
postgres=# SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE datname = 'epsdb';drop database epsdb;
ReplyDeletepg_terminate_backend
----------------------
t
t
t
t
(4 rows)
* need to run both command in one script to avoid new session created