Re: Creating new database - Mailing list pgsql-general

From Raymond O'Donnell
Subject Re: Creating new database
Date
Msg-id 4B03F5D1.9070004@iol.ie
Whole thread Raw
In response to Creating new database  (Malcolm Warren <malcolm@villeinitalia.com>)
List pgsql-general
On 18/11/2009 11:48, Malcolm Warren wrote:
> Let's say the old database is called database1, and I've created a
> new database2.
>
> When I import the pg_dump into database2, it tells me that the tables
>  already exist (obviously it's talking about the tables in
> database1). But I surely I've created a new database called
> database2? Why is it stopping me from creating the same tables in the
> new database?
>
> Same sort of problem with psql: If I run 'psql database2' then I see
> everything from database1 as well. What am I missing here?

Did you use database1 as a template for database 2?

   createdb -T database1 ....

If so, then database2 will have the same structure as database1.

If not, did the tables get created in the database "template1" at some
point? If you don't specify a template, CREATE DATABASE (which createdb
wraps) uses template1 as the template.

In any case, CREATE DATABASE always uses another database as a template
from which to copy the structure. By default, it uses template1, and if
that somehow gets polluted (happens to us all betimes) then you also
have template0 to fall back on.

I'm guessing that one of these scenarios is causing your problem.

Ray.


--
Raymond O'Donnell :: Galway :: Ireland
rod@iol.ie

pgsql-general by date:

Previous
From: Malcolm Warren
Date:
Subject: Creating new database
Next
From: Dave Coventry
Date:
Subject: column does not exist error