Search Postgresql Archives

Re: Creating new database

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxx

-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux