Re: Droping a database even if someone is connected

From: Oliver Elphick <olly(at)lfix(dot)co(dot)uk>
To: Eric Audet <eaudet(at)scc(dot)ca>
Cc: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: Droping a database even if someone is connected
Date: 2003-03-16 07:08:40
Message-ID: 1047798520.8983.202.camel@linda.lfix.co.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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.

--
Oliver Elphick Oliver(dot)Elphick(at)lfix(dot)co(dot)uk
Isle of Wight, UK http://www.lfix.co.uk/oliver
GPG: 1024D/3E1D0C1C: CA12 09E0 E8D5 8870 5839 932A 614D 4C34 3E1D 0C1C
========================================
"Bless them which persecute you; bless, and curse not.
Rejoice with them that do rejoice, and weep with them
that weep. Recompense to no man evil for evil. Provide
things honest in the sight of all men."
Romans 12:14,15,17

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2003-03-16 07:24:18 Re: Droping a database even if someone is connected
Previous Message shreedhar 2003-03-16 05:06:33 Re: query optimisation