Skip site navigation (1) Skip section navigation (2)

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 (view raw or flat)
Thread:
Lists: pgsql-adminpgsql-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

pgsql-novice by date

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

pgsql-admin by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group