Re: Copying data from table to table (cloned tables)

From: daq <daq(at)ugyvitelszolgaltato(dot)hu>
To: "Fourat Zouari" <fourat(at)gmail(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: Copying data from table to table (cloned tables)
Date: 2006-10-10 09:22:28
Message-ID: 5168869156.20061010112228@ugyvitelszolgaltato.hu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin pgsql-novice


FZ> Hello all,
FZ> Any one could suggest the best way to copy data from table to table in the
FZ> same db, the reason why am seeking for this is that the first table is
FZ> becoming very big, and old data has no reason why to stay there, so i
FZ> created a cloned table but without indexes and constraints (lighter) and now
FZ> i would like to copy 'some' data from first to second table (copied data is
FZ> data older than 3 months, i have a timestamp column).

FZ> In other way, i have a table called 'hotqueues' where i store fresh messages
FZ> queued, once messages are treated, they stay in 'hotqueues' but with a flag
FZ> indicating that their arent queued for treatment..
FZ> so in this way, data will rest there forever, slowing down any searches in
FZ> that table, the solution was to copy old messages to another table called
FZ> 'coldqueues' that has the same structure as 'hotqueues' but lighter (without
FZ> constraints and indexes).
FZ> How to copy these data with 100% data-loose free.

FZ> Thanks for any help you can provide.

A simple solution:

INSERT INTO coldqueues SELECT * FROM hotqueues where ...;

See documentation page: http://www.postgresql.org/docs/8.1/static/sql-insert.html

DAQ

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Fourat Zouari 2006-10-10 09:35:04 Re: [NOVICE] Copying data from table to table (cloned tables)
Previous Message Adam Radlowski 2006-10-10 06:48:31 Re: ERROR: invalid page header in block

Browse pgsql-novice by date

  From Date Subject
Next Message Fourat Zouari 2006-10-10 09:35:04 Re: [NOVICE] Copying data from table to table (cloned tables)
Previous Message Simon-Timothy Folaji 2006-10-10 09:07:53 unsubscribe