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