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

From: Nick Barr <nicky(at)chuckie(dot)co(dot)uk>
To: "Karl O(dot) Pinc" <kop(at)meme(dot)com>
Cc: Sally Sally <dedeb17(at)hotmail(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: making a copy of a table within the same database
Date: 2004-03-03 15:25:14
Message-ID: 4045F8DA.50302@chuckie.co.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Karl O. Pinc wrote:

>
> On 2004.03.03 09:00 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?
>
>
> You might want to look at SELECT INTO ... .
>
> Karl <kop(at)meme(dot)com>
> Free Software: "You don't pay back, you pay forward."
> -- Robert A. Heinlein
>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster

See

http://www.postgresql.org/docs/7.4/static/sql-selectinto.html
http://www.postgresql.org/docs/7.4/static/sql-createtableas.html

for more info.

Nick

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Oliver Elphick 2004-03-03 15:37:20 Re: making a copy of a table within the same database
Previous Message Karl O. Pinc 2004-03-03 15:22:59 Re: making a copy of a table within the same database