首页 > 数据库技术 > 详细

postgreSQLG关闭活动的connection、删除活动的数据库

时间:2014-01-26 15:44:19      阅读:403      评论:0      收藏:0      [点我收藏+]

First, find the activities that are taken place against the target database, you can query thepg_stat_activity view as the following query:

SELECT
    *
FROM
    pg_stat_activity
WHERE
    datname = target_database;

 

 Second, terminate the active connections by issuing the following query:

bubuko.com,布布扣
SELECT
    pg_terminate_backend (pg_stat_activity.pid)
FROM
    pg_stat_activity
WHERE
    pg_stat_activity.datname = target_database;
bubuko.com,布布扣
bubuko.com,布布扣
Notice that if you use PostgreSQL version 9.1 or earlier, use the procpid column instead of the pid column because PostgreSQL changed procid column to pid column since version 9.2
bubuko.com,布布扣

Third, execute the DROP DATABASE statement:

DROP DATABASE target_database;

postgreSQLG关闭活动的connection、删除活动的数据库

原文:http://www.cnblogs.com/paulbai/p/3533920.html

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