Cannot drop template1

Started by Raymond O'Donnellover 21 years ago3 messagesgeneral
Jump to latest

Greetings all,

I'm trying to drop template1 so that I can re-create it from
template0 - I made the mistake of loading a whole pile of crud into
template1 (luckily it's a test installation on my WinXP Pro laptop).

However, when using -

dropdb -U postgres -W template1

at the command line, all I get back is "dropdb: database removal
failed: ERROR: cannot drop the currently open database". This is
even after a cold start; the DBMS service has only just been started
and is doing no other work whatsoever - there are no other
connections to template1 or indeed any other database.

I've tried connecting to a different database and dropping template1
from there, only to be told that I cannot drop a template database.
I've also tried connecting to template0, but was told that template0
is not accepting connections.

Any suggestions will be appreciated!

--Ray.

-------------------------------------------------------------
Raymond O'Donnell http://www.galwaycathedral.org/recitals
rod@iol.ie Galway Cathedral Recitals
-------------------------------------------------------------

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Raymond O'Donnell (#1)
Re: Cannot drop template1

"Raymond O'Donnell" <rod@iol.ie> writes:

dropdb -U postgres -W template1
at the command line, all I get back is "dropdb: database removal
failed: ERROR: cannot drop the currently open database".

That's because the dropdb command itself connects to template1.

See the article on techdocs.postgresql.org about rebuilding template1
to find out about all the gotchas and workarounds needed to do this.

regards, tom lane

In reply to: Tom Lane (#2)
Re: Cannot drop template1

On 14 Dec 2004 at 9:27, Tom Lane wrote:

See the article on techdocs.postgresql.org about rebuilding template1
to find out about all the gotchas and workarounds needed to do this.

Found it - thanks!

--Ray.

-------------------------------------------------------------
Raymond O'Donnell http://www.galwaycathedral.org/recitals
rod@iol.ie Galway Cathedral Recitals
-------------------------------------------------------------