Re: making a copy of a table within the same database

From: Mike Mascari <mascarm(at)mascari(dot)com>
To: Sally Sally <dedeb17(at)hotmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: making a copy of a table within the same database
Date: 2004-03-03 15:19:01
Message-ID: 4045F765.707@mascari.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Sally Sally wrote:

> I wanted to dump the contents of one table to another (with a different
> name) within the same database. I am looking at pg_restore and it
> doesn't seem to have the option of specifying the name of the table we
> want to dump to, only the name we want to dump from. Does this mean I
> have to create the table and do an sql statement to copy the table? Is
> this the best way?

If you want a copy of the data and the fundamental table design, not
including constraints, triggers, indexes, foreign keys, etc.:

CREATE TABLE foo AS
SELECT * FROM bar;

...

Mike Mascari

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Jan Poslusny 2004-03-03 15:19:19 Re: making a copy of a table within the same database
Previous Message Nick Barr 2004-03-03 15:13:30 Re: How index are running and how to optimise ?