Re: Droping a database even if someone is connected - Mailing list pgsql-general

From Tom Lane
Subject Re: Droping a database even if someone is connected
Date
Msg-id 18950.1047799458@sss.pgh.pa.us
Whole thread Raw
In response to Re: Droping a database even if someone is connected  (Oliver Elphick <olly@lfix.co.uk>)
List pgsql-general
Oliver Elphick <olly@lfix.co.uk> writes:
> On Thu, 2003-03-13 at 19:19, Eric Audet wrote:
>> Is there a way to drop a database even if someone is connected to it?
>>
>> I use a perl script that
>> 1) drop the database, (dropdb)
>> 2) create a new database, (createdb)
>> 3) restore a database from a dump (psql databasename <dumpfile)
>>
>> When the drop does not work, everything else fails!

> If 1) fails, identify the relevant backend process and kill it. Then try
> again.

Actually, what's the need to drop the database at all?  Running pg_dump
with -c option would allow the dump to be loaded into the existing DB.

            regards, tom lane

pgsql-general by date:

Previous
From: "shreedhar"
Date:
Subject: Re: query optimisation
Next
From: "Carmen Wai"
Date:
Subject: Upgrade to Postgresql 7.3.2