Re: Copy Database Structure

From: Jeff Self <jself(at)nngov(dot)com>
To: cgoodfellow(at)tealuxe(dot)com
Cc: "Pgsql-Novice (E-mail)" <pgsql-novice(at)postgresql(dot)org>
Subject: Re: Copy Database Structure
Date: 2002-03-01 16:53:34
Message-ID: 1015001614.5290.24.camel@personnel_test
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Try pg_dump -s dbname > outputfile
This gives you the schema of the database but without the data.

Then to reload it:
psql -e dbname < outputfile

Make sure you create the database first and have the owner set properly.
You may need to go into the outputfile and change the owner for the new
database.

On Fri, 2002-03-01 at 11:19, Christopher A. Goodfellow wrote:
> I have an existing database that I want to copy all the tables,
> relationships, and keys to another database.
> Does anyone know how to duplicate a database?
> I don't need to copy the data but I could always delete all the records
> after the copy if needed.
>
> Chris Goodfellow
> Director of IT
> Tealuxe, Inc.
> 25 Kenwood Circle
> Franklin, MA 02038
> Voice: (508) 520-7887 Ext:22
> Fax: (508) 528-8999
> HTTP://www.tealuxe.com
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to majordomo(at)postgresql(dot)org
--
Jeff Self
Information Technology Analyst
Department of Personnel
City of Newport News
2400 Washington Ave.
Newport News, VA 23607
757-926-6930

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Christopher A. Goodfellow 2002-03-01 17:25:46 Re: Copy Database Structure
Previous Message Christopher A. Goodfellow 2002-03-01 16:19:22 Copy Database Structure