其中“test_demo”为数据库名称

SELECT pg_terminate_backend(pg_stat_activity.pid)
FROM pg_stat_activity
WHERE datname='test_demo' AND pid<>pg_backend_pid();
pg_terminate_backend

DROP DATABASE test_demo

更多推荐