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

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:

postgreSQLG关闭活动的connection、删除活动的数据库
SELECT
    pg_terminate_backend (pg_stat_activity.pid)
FROM
    pg_stat_activity
WHERE
    pg_stat_activity.datname = target_database;
postgreSQLG关闭活动的connection、删除活动的数据库
postgreSQLG关闭活动的connection、删除活动的数据库
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
postgreSQLG关闭活动的connection、删除活动的数据库

Third, execute the DROP DATABASE statement:

DROP DATABASE target_database;

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

上一篇:mysql 排序后获得某行的位置


下一篇:WebRTC架构和协议栈-zz