DROP DATABASE, but still there

Started by Robert Fitzpatrickover 21 years ago6 messagesgeneral
Jump to latest
#1Robert Fitzpatrick
robert@webtent.com

What does it mean when you drop a database and then recreate with the
same name and all the objects are still there. I want to wipe out the db
and put back from pg_restore. After I re-create the db, all the old
tables are back before I run pg_restore.

--
Robert

#2Doug McNaught
doug@mcnaught.org
In reply to: Robert Fitzpatrick (#1)
Re: DROP DATABASE, but still there

Robert Fitzpatrick <robert@webtent.com> writes:

What does it mean when you drop a database and then recreate with the
same name and all the objects are still there. I want to wipe out the db
and put back from pg_restore. After I re-create the db, all the old
tables are back before I run pg_restore.

Check the 'template1' database to see if the tables got put in there
by mistake at some point.

-Doug

#3Robert Fitzpatrick
robert@webtent.com
In reply to: Doug McNaught (#2)
Re: DROP DATABASE, but still there

On Thu, 2004-11-11 at 14:03, Doug McNaught wrote:

Robert Fitzpatrick <robert@webtent.com> writes:

What does it mean when you drop a database and then recreate with the
same name and all the objects are still there. I want to wipe out the db
and put back from pg_restore. After I re-create the db, all the old
tables are back before I run pg_restore.

Check the 'template1' database to see if the tables got put in there
by mistake at some point.

Yeah, I was just starting to realize that these objects that keep coming
back are in the template1 as well.....any reason why I shouldn't drop
the template1 and re-create like any other?

--
Robert

#4Bruno Wolff III
bruno@wolff.to
In reply to: Robert Fitzpatrick (#3)
Re: DROP DATABASE, but still there

On Thu, Nov 11, 2004 at 14:17:45 -0500,
Robert Fitzpatrick <robert@webtent.com> wrote:

On Thu, 2004-11-11 at 14:03, Doug McNaught wrote:

Robert Fitzpatrick <robert@webtent.com> writes:

What does it mean when you drop a database and then recreate with the
same name and all the objects are still there. I want to wipe out the db
and put back from pg_restore. After I re-create the db, all the old
tables are back before I run pg_restore.

Check the 'template1' database to see if the tables got put in there
by mistake at some point.

Yeah, I was just starting to realize that these objects that keep coming
back are in the template1 as well.....any reason why I shouldn't drop
the template1 and re-create like any other?

I think you need to use the -T option if you do this to have a copy made
of template0 instead of the default of template1.

#5Bruce Momjian
bruce@momjian.us
In reply to: Robert Fitzpatrick (#3)
Re: DROP DATABASE, but still there

Robert Fitzpatrick <robert@webtent.com> writes:

Yeah, I was just starting to realize that these objects that keep coming
back are in the template1 as well.....any reason why I shouldn't drop
the template1 and re-create like any other?

You can do that but you'll have to do:

CREATE DATABASE template1 WITH template = 'template0'

--
greg

#6Tom Lane
tgl@sss.pgh.pa.us
In reply to: Bruce Momjian (#5)
Re: DROP DATABASE, but still there

Greg Stark <gsstark@mit.edu> writes:

Robert Fitzpatrick <robert@webtent.com> writes:

Yeah, I was just starting to realize that these objects that keep coming
back are in the template1 as well.....any reason why I shouldn't drop
the template1 and re-create like any other?

You can do that but you'll have to do:
CREATE DATABASE template1 WITH template = 'template0'

Also there are several safety interlocks you'll have to defeat, IIRC.
It's not rocket science but I'd recommend consulting the writeup on
techdocs.postgresql.org about the exact process for recreating
template1.

regards, tom lane