Re: dropdb: database removal failed: active sessions - Mailing list pgsql-general

From Scott Marlowe
Subject Re: dropdb: database removal failed: active sessions
Date
Msg-id CAOR=d=23rE6=BNPetxfmWJmLGYAYxXqjUnwbhjJH-Nvp=LbQ5Q@mail.gmail.com
Whole thread Raw
In response to Re: dropdb: database removal failed: active sessions  (John R Pierce <pierce@hogranch.com>)
List pgsql-general
On Mon, Aug 29, 2011 at 2:39 PM, John R Pierce <pierce@hogranch.com> wrote:
> any connection to the database, even idle, will prevent a drop database.
>
> try...
>
>    select pg_terminate_backend(procpid) from pg_stat_activity where datname
> = 'database1';
>
> that will snuff those processes.  then you can drop the database, assuming
> the clients don't immediately reconnect.

If you lose your connection at this point you'll know who was
connected to that database as well.

Yes, I have done that before.

pgsql-general by date:

Previous
From: Lonni J Friedman
Date:
Subject: Re: heavy swapping, not sure why
Next
From: Scott Marlowe
Date:
Subject: Re: heavy swapping, not sure why