1、删除数据库时,报错存在其他会话连接
## 错误现象,存在其他的会话连接正在使用数据库
ERROR: database "cs" is being accessed by other users
DETAIL: There is 1 other session using the database.
2、解决方法
## 终止被删除数据库下所有的会话连接
select pg_terminate_backend(pg_stat_activity.pid) from pg_stat_activity where pg_stat_activity.datname = 'cs' and pid <> pg_backend_pid();
3、再次删除即可
postgres=# drop database cs;
DROP DATABASE