> > Anyway, you can use `psql' to query the activity tables using something > > like "SELECT procpid FROM pg_stat_activity WHERE datname = 'dbtodrop'" > > and see which backend pids need to be killed, then use 'pg_ctl kill > > signame pid' to kill them. A bit of powershell, cmd.exe, etc should do > > the job, though I agree that for win32 a builtin "pg_kill_backend()" > > function would be nicer, in that you could just execute a query like: Yep, pg_ctl did the trick in the end. Thanks! $ENV{PATH} = ''; # this automatically gets reset (and retainted) after this script finishes local our $sth = $dbh->prepare("SELECT procpid FROM pg_stat_activity WHERE datname=? order by procpid") or die("Couldn't prepare statement: " . $dbh->diestr); $sth->execute($ENV{db}) or die("Couldn't execute statement: " . $sth- >diestr); local our @data; while (@data = $sth->fetchrow_array()) { $r->print("Killing $data[0]...<br>"); system('"c:\program files\postgresql\8.3\bin\pg_ctl.exe" kill TERM ' . $data[0]) == 0 or die("Couldn't kill process $data[0]."); } $sth->finish; $r->print("All done."); Kev