首页 > 数据库技术 > 详细

[Postgres] drop database , but the database is being accessed by other users

时间:2015-11-04 11:28:04      阅读:1120      评论:0      收藏:0      [点我收藏+]

1.

postgres=# drop database otmstest;
ERROR:  database "otmstest" is being accessed by other users
DETAIL:  There are 9 other sessions using the database.
postgres=# SELECT
postgres-#     pg_terminate_backend(pid)
postgres-# FROM
postgres-#     pg_stat_activity
postgres-# WHERE
postgres-#     -- don‘t kill my own connection!
postgres-#     pid <> pg_backend_pid()
postgres-#     -- don‘t kill the connections to other databases
postgres-#     AND datname = ‘database_name‘
postgres-#     ;

2. maybe restart postgres .

sudo service postgresql restart

 

[Postgres] drop database , but the database is being accessed by other users

原文:http://www.cnblogs.com/Uncho/p/4935216.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!