DROP DATABASE ERROR: database 'target_database' is being accessed by other users

Сообщение об ошибке

Deprecated function: The each() function is deprecated. This message will be suppressed on further calls в функции menu_set_active_trail() (строка 2405 в файле /var/www/notes7/includes/menu.inc).

Проявляется так:

postgres=# drop database test;
ERROR:  database "test" is being accessed by other users
DETAIL:  There is 1 other session using the database.

Целиком читать тут

First, find the activities that are taken place against the target database,
you can query the pg_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:

SELECT pg_terminate_backend (pg_stat_activity.pid) FROM pg_stat_activity WHERE pg_stat_activity.datname = 'target_database';

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 Third, execute the DROP DATABASE statement:

DROP DATABASE target_database;

Добавить комментарий