PostgreSQL 关闭session链接,删除数据库方法
发布时间:2020-12-13 17:01:50 所属栏目:百科 来源:网络整理
导读:PostgreSQL 关闭session链接,删除数据库方法 PostgreSQL 中 有时候想删除数据库(drop database swiftliveqaapi;),发现提示“ERROR: database "xxxxxx" is being accessed by other usersDETAIL: There are 30 other sessions using the database.” 意思
PostgreSQL 关闭session链接,删除数据库方法 PostgreSQL 中 有时候想删除数据库(drop database swiftliveqaapi;),发现提示“ERROR: database "xxxxxx" is being accessed by other usersDETAIL: There are 30 other sessions using the database.” 意思是 有其他用户在连接数据库,不能删除。 解决方法: 用psql 登录进入, 执行语句:
SELECTpg_terminate_backend(pid)FROMpg_stat_activityWHEREdatname='
数据库名'ANDpid<>pg_backend_pid();
然后就可以删除数据库了。 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |