pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Ross J. Reedstrom <reedstrm@rice.edu>
To: Lindell Alderman <lindell@axispt.com>
Cc: pgsql-admin@postgresql.org
Subject: Re: backup/restore
Date: Mon, 11 Sep 2000 09:54:36 -0500
Message-ID: <20000911095436.D13906@rice.edu> (raw)
In-Reply-To: <20000908161320.C18742@axispt.com>
References: <20000908161320.C18742@axispt.com>

On Fri, Sep 08, 2000 at 04:13:20PM -0700, Lindell Alderman wrote:
> I am trying to backup and restore a database, but when run the following:
> 
> dropdb test
> createdb test
> 
> I find that the newly created database "test" is not empty but still has
> all of the old relations and tables in it.  How do I destroy a database
> so that it is truly gone!?!?!?  I need a totally clean databaes to restore
> my data into.

I'm going to put on my swami hat and read your mind now:

Ah, your using Linux, specifically the Debian distribution, are you not?

The problem is that psql by default connects to a database named the same
as the unix username, except on Debian, where it defaults to connecting
to the template1 database, since this is guaranteed to always exist. The
primary purpose of template1 is to serve as a (surprise) template to
build new databases on.

What does this mean? Well, if you put anything in template1 (like install
the pgpsql scipt language) it will, be default, be installed in all your
new dbs.

Unfortunately, if you accidently create tables in template1 (on Debian,
just forgetting to put the db name in a psql command line will do it),
they'll end up getting copied into every new db after that.

So, connect to template1, and delete everything you don't want from there.

Ross (learned from experience, I did)
-- 
Ross J. Reedstrom, Ph.D., <reedstrm@rice.edu> 
NSBRI Research Scientist/Programmer
Computer and Information Technology Institute
Rice University, 6100 S. Main St.,  Houston, TX 77005



view thread (9+ messages)  latest in thread

Message-ID: <20000911095436.D13906@rice.edu>
Permalink:  ../20000911095436.D13906@rice.edu/
Also on:    postgresql.org/message-id/20000911095436.D13906@rice.edu

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-admin@postgresql.org
  Cc: reedstrm@rice.edu, lindell@axispt.com
  Subject: Re: backup/restore
  In-Reply-To: <20000911095436.D13906@rice.edu>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox