From: | "Guido Barosio" <gbarosio(at)gmail(dot)com> |
---|---|
To: | "Sean Davis" <sdavis2(at)mail(dot)nih(dot)gov> |
Cc: | KeithW(at)narrowpathinc(dot)com, "PostgreSQL Novice" <pgsql-novice(at)postgresql(dot)org> |
Subject: | Re: Copy data from one table to another |
Date: | 2006-02-24 19:19:58 |
Message-ID: | f7f6b4c70602241119g14334863odb0cee53d080d380@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice |
If you want an exact copy (using another method), without indexes or relying
objects, you shall try:
`SELECT * INTO table_b FROM table_a`
Check the manpages, SELECT, or in the psql shell: \h SELECT
--------------
Another option:
pg_dump the data as INSERT replacing the table name on the result with the
new table name, then psql'it.
----------
Another option:
run a classic pg_dump, using COPY, and replace the table name with the new
one.
-------
Consider in all cases, that the index maintenance will be a cost if you
already have the indexes created before running the populate. You may want
to drop that indexes, populate and recreate indexes after.
Vacuum analyze should be the last command on this move, afaik.
Best wishes,
Guido
On 2/24/06, Sean Davis <sdavis2(at)mail(dot)nih(dot)gov> wrote:
>
> On 2/24/06 1:42 PM, "Keith Worthington" <keithw(at)narrowpathinc(dot)com> wrote:
>
> > Hi All,
> >
> > Would someone be so kind as to remind me of the syntax required to copy
> data
> > from one table to another?
>
> Hi, Keith. Will:
>
> Insert into table2 [column1, ...]
> Select * from table1;
>
> Do what you want?
>
> Sean
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to majordomo(at)postgresql(dot)org so that your
> message can get through to the mailing list cleanly
>
--
/"\ ASCII Ribbon Campaign .
\ / - NO HTML/RTF in e-mail .
X - NO Word docs in e-mail .
/ \ -----------------------------------------------------------------
From | Date | Subject | |
---|---|---|---|
Next Message | Richard Kut | 2006-02-24 19:47:01 | Re: Transaction Questions |
Previous Message | Sean Davis | 2006-02-24 18:58:01 | Re: Copy data from one table to another |