Re: Droping a database even if someone is connected

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Oliver Elphick <olly(at)lfix(dot)co(dot)uk>
Cc: Eric Audet <eaudet(at)scc(dot)ca>, pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: Droping a database even if someone is connected
Date: 2003-03-16 07:24:18
Message-ID: 18950.1047799458@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Oliver Elphick <olly(at)lfix(dot)co(dot)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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Carmen Wai 2003-03-16 09:24:21 Upgrade to Postgresql 7.3.2
Previous Message Oliver Elphick 2003-03-16 07:08:40 Re: Droping a database even if someone is connected