Re: Creating new database - Mailing list pgsql-general

From Joao Ferreira gmail
Subject Re: Creating new database
Date
Msg-id 1258557168.4631.33.camel@debj5n.critical.pt
Whole thread Raw
In response to Creating new database  (Malcolm Warren <malcolm@villeinitalia.com>)
Responses Re: Creating new database  (Scott Marlowe <scott.marlowe@gmail.com>)
List pgsql-general
I'dd suggest:

pgdumpall --clean > dump.sql

edit the dump.sql file by hand replacing database name and owners and
so...

then reload into the new DB with psql -f dump.sql postgres

this does all the work except creation of users and databases

should give you an exact replica with all data inside

see "man pgdumpall"

Joao

On Wed, 2009-11-18 at 12:48 +0100, Malcolm Warren wrote:
> Dear All,
>
>
> I've been using a single database for many years.
> I'd now like to create a new separate database with most of the same
> tables, so that I don't have to re-write my code, I'd like to just use
> a different Tomcat datasource to access it.
>
> I had imagined this would be as simple as :
> 1) using createdb, to create a database with a different name, maybe
> with a different postgres user assigned to it,
> 2) using a pg_dump from the original database to import the table
> creation.
>
> However it doesn't appear to be that simple.
>
> 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?
>
>
>
> Thanks for your time.
>
> Malcolm Warren
>
>
>
>


pgsql-general by date:

Previous
From: "Daniel Verite"
Date:
Subject: Re: passing parameters to multiple statements
Next
From: Malcolm Warren
Date:
Subject: [Fwd: Re: Creating new database]